@@ -75,6 +75,7 @@ const SetsView = () => {
7575 const [ embedLink , setEmbedLink ] = useState ( "" )
7676 const [ newTitle , setNewTitle ] = useState ( set . title )
7777 const [ timeError , setTimeError ] = useState ( false )
78+ const [ randomKey , setRandomKey ] = useState ( Math . random ( ) )
7879
7980 let partUrl = location . state . vodUrl . split ( '/' )
8081 let twitchId = partUrl . pop ( ) || partUrl . pop ( )
@@ -88,32 +89,26 @@ const SetsView = () => {
8889 } )
8990
9091 useEffect ( ( ) => {
91- setSkipTime ( newStartTime )
92- } , [ newStartTime ] )
93-
94- useEffect ( ( ) => {
95- if ( skipTime ) {
96- let split = skipTime . format ( 'HH:mm:ss' ) . split ( ':' )
97- if ( split . length === 3 ) {
98- let hours = split [ 0 ]
99- let minutes = split [ 1 ]
100- let seconds = split [ 2 ]
101- let twitchFormat = ""
102- if ( hours !== "00" ) {
103- twitchFormat = twitchFormat . concat ( hours . replace ( / ^ 0 + / , '' ) , "h" )
104- }
105- if ( minutes !== "00" ) {
106- twitchFormat = twitchFormat . concat ( minutes . replace ( / ^ 0 + / , '' ) , "m" )
107- } else {
108- twitchFormat = twitchFormat . concat ( "0m" )
109- }
110- if ( seconds !== "00" ) {
111- twitchFormat = twitchFormat . concat ( seconds . replace ( / ^ 0 + / , '' ) , "s" )
112- } else {
113- twitchFormat = twitchFormat . concat ( "0s" )
114- }
115- setEmbedLink ( "https://player.twitch.tv/?video=" + twitchId + "&t=" + twitchFormat + "&parent=localhost&muted=true" )
92+ let split = skipTime . format ( 'HH:mm:ss' ) . split ( ':' )
93+ if ( split . length === 3 ) {
94+ let hours = split [ 0 ]
95+ let minutes = split [ 1 ]
96+ let seconds = split [ 2 ]
97+ let twitchFormat = ""
98+ if ( hours !== "00" ) {
99+ twitchFormat = twitchFormat . concat ( hours . replace ( / ^ 0 + / , '' ) , "h" )
100+ }
101+ if ( minutes !== "00" ) {
102+ twitchFormat = twitchFormat . concat ( minutes . replace ( / ^ 0 + / , '' ) , "m" )
103+ } else {
104+ twitchFormat = twitchFormat . concat ( "0m" )
105+ }
106+ if ( seconds !== "00" ) {
107+ twitchFormat = twitchFormat . concat ( seconds . replace ( / ^ 0 + / , '' ) , "s" )
108+ } else {
109+ twitchFormat = twitchFormat . concat ( "0s" )
116110 }
111+ setEmbedLink ( "https://player.twitch.tv/?video=" + twitchId + "&t=" + twitchFormat + "&parent=localhost&muted=true" )
117112 }
118113 } )
119114
@@ -127,7 +122,7 @@ const SetsView = () => {
127122 // onClick={(event: any) => event.stopPropagation()}
128123 >
129124 < LocalizationProvider dateAdapter = { AdapterMoment } >
130- < Box sx = { { display : 'flex' , flexDirection : 'column' , justifyContent : 'space-around' , height :'100vh' , width : '70vw ' , padding : '20px' } } >
125+ < Box sx = { { display : 'flex' , flexDirection : 'column' , justifyContent : 'space-around' , height :'100vh' , minWidth : '50vw ' , padding : '20px' } } >
131126 < Typography variant = "h6" component = "h2" textAlign = "center" gutterBottom >
132127 Edit Match
133128 </ Typography >
@@ -137,18 +132,20 @@ const SetsView = () => {
137132 src = { embedLink }
138133 height = '100%'
139134 width = '100%'
135+ key = { randomKey }
140136 >
141137 </ iframe >
142138 </ Card >
143139 < TextField
144140 className = "textfield"
145141 label = "Title"
146142 defaultValue = { newTitle }
147- onBlur = { ( event ) => {
143+ onChange = { ( event ) => {
148144 event . stopPropagation ( )
149145 event . preventDefault ( )
150146 setNewTitle ( event . target . value )
151147 } }
148+ helperText = { newTitle . length + "/100 | YouTube title character limit" }
152149 />
153150 < Box sx = { { width : '100%' , display : 'flex' , justifyContent : 'space-between' } } >
154151 < TimePicker
@@ -165,7 +162,7 @@ const SetsView = () => {
165162 className = "timepicker"
166163 />
167164 < Tooltip title = "Skip to start" >
168- < IconButton onClick = { ( ) => setSkipTime ( newStartTime ) } >
165+ < IconButton onClick = { ( ) => newStartTime === skipTime ? setRandomKey ( Math . random ( ) ) : setSkipTime ( newStartTime ) } >
169166 < SkipNextIcon />
170167 </ IconButton >
171168 </ Tooltip >
@@ -185,7 +182,7 @@ const SetsView = () => {
185182 className = "timepicker"
186183 />
187184 < Tooltip title = "Skip to end" >
188- < IconButton onClick = { ( ) => setSkipTime ( newEndTime ) } >
185+ < IconButton onClick = { ( ) => newEndTime === skipTime ? setRandomKey ( Math . random ( ) ) : setSkipTime ( newEndTime ) } >
189186 < SkipNextIcon />
190187 </ IconButton >
191188 </ Tooltip >
0 commit comments