@@ -284,18 +284,31 @@ function App({ preview, previewId }) {
284284 const checkForUpdates = ( ) => {
285285 Logger . log ( 'info' , 'Checking for new release timestamp.' ) ;
286286
287- ReleaseLoader . loadConfig ( ) . then ( ( config ) => {
287+ ReleaseLoader . loadConfig ( ) . then ( ( release ) => {
288288 if ( releaseTimestampRef ?. current === null ) {
289- releaseTimestampRef . current = config . releaseTimestamp ;
290- } else if ( releaseTimestampRef ?. current !== config . releaseTimestamp ) {
291- const redirectUrl = new URL ( window . location . href ) ;
292- redirectUrl . searchParams . set (
293- 'releaseTimestamp' ,
294- config . releaseTimestamp
295- ) ;
296- redirectUrl . searchParams . set ( 'releaseVersion' , config . releaseVersion ) ;
297-
298- window . location . replace ( redirectUrl ) ;
289+ releaseTimestampRef . current = release . releaseTimestamp ;
290+ } else if ( releaseTimestampRef ?. current !== release . releaseTimestamp ) {
291+ if (
292+ release . releaseTimestamp !== null &&
293+ release . releaseVersion !== null
294+ ) {
295+ const redirectUrl = new URL ( window . location . href ) ;
296+ redirectUrl . searchParams . set (
297+ 'releaseTimestamp' ,
298+ release . releaseTimestamp
299+ ) ;
300+ redirectUrl . searchParams . set (
301+ 'releaseVersion' ,
302+ release . releaseVersion
303+ ) ;
304+
305+ window . location . replace ( redirectUrl ) ;
306+ } else {
307+ Logger . log (
308+ 'info' ,
309+ 'Release timestamp or version null, not redirecting.'
310+ ) ;
311+ }
299312 }
300313 } ) ;
301314 } ;
@@ -350,56 +363,70 @@ function App({ preview, previewId }) {
350363 ! currentUrl . searchParams . has ( 'releaseTimestamp' )
351364 ) {
352365 ReleaseLoader . loadConfig ( ) . then ( ( release ) => {
353- currentUrl . searchParams . set (
354- 'releaseTimestamp' ,
355- release . releaseTimestamp
356- ) ;
357- currentUrl . searchParams . set ( 'releaseVersion' , release . releaseVersion ) ;
366+ if (
367+ release . releaseTimestamp !== null &&
368+ release . releaseVersion !== null
369+ ) {
370+ currentUrl . searchParams . set (
371+ 'releaseTimestamp' ,
372+ release . releaseTimestamp
373+ ) ;
374+ currentUrl . searchParams . set (
375+ 'releaseVersion' ,
376+ release . releaseVersion
377+ ) ;
358378
359- window . history . replaceState ( null , '' , currentUrl ) ;
379+ window . history . replaceState ( null , '' , currentUrl ) ;
380+ } else {
381+ Logger . log (
382+ 'info' ,
383+ 'Release timestamp or version null, not setting query parameters.'
384+ ) ;
385+ }
360386 } ) ;
361- }
362387
363- document . addEventListener ( 'screen' , screenHandler ) ;
364- document . addEventListener ( 'reauthenticate' , reauthenticateHandler ) ;
365- document . addEventListener ( 'contentEmpty' , contentEmpty ) ;
366- document . addEventListener ( 'contentNotEmpty' , contentNotEmpty ) ;
367- document . addEventListener ( 'keypress' , handleKeyboard ) ;
388+ document . addEventListener ( 'screen' , screenHandler ) ;
389+ document . addEventListener ( 'reauthenticate' , reauthenticateHandler ) ;
390+ document . addEventListener ( 'contentEmpty' , contentEmpty ) ;
391+ document . addEventListener ( 'contentNotEmpty' , contentNotEmpty ) ;
392+ document . addEventListener ( 'keypress' , handleKeyboard ) ;
368393
369- checkLogin ( ) ;
394+ checkLogin ( ) ;
370395
371- checkForUpdates ( ) ;
396+ checkForUpdates ( ) ;
372397
373- ConfigLoader . loadConfig ( ) . then ( ( config ) => {
374- releaseTimestampIntervalRef . current = setInterval (
375- checkForUpdates ,
376- config . releaseTimestampIntervalTimeout ??
377- releaseTimestampIntervalTimeoutDefault
378- ) ;
379- } ) ;
380- }
398+ ConfigLoader . loadConfig ( ) . then ( ( config ) => {
399+ releaseTimestampIntervalRef . current = setInterval (
400+ checkForUpdates ,
401+ config . releaseTimestampIntervalTimeout ??
402+ releaseTimestampIntervalTimeoutDefault
403+ ) ;
404+ } ) ;
405+ }
381406
382- return function cleanup ( ) {
383- Logger . log ( 'info' , 'Unmounting App.' ) ;
407+ // eslint-disable-next-line consistent-return
408+ return function cleanup ( ) {
409+ Logger . log ( 'info' , 'Unmounting App.' ) ;
384410
385- document . removeEventListener ( 'keypress' , handleKeyboard ) ;
386- document . removeEventListener ( 'screen' , screenHandler ) ;
387- document . removeEventListener ( 'reauthenticate' , reauthenticateHandler ) ;
388- document . removeEventListener ( 'contentEmpty' , contentEmpty ) ;
389- document . removeEventListener ( 'contentNotEmpty' , contentNotEmpty ) ;
411+ document . removeEventListener ( 'keypress' , handleKeyboard ) ;
412+ document . removeEventListener ( 'screen' , screenHandler ) ;
413+ document . removeEventListener ( 'reauthenticate' , reauthenticateHandler ) ;
414+ document . removeEventListener ( 'contentEmpty' , contentEmpty ) ;
415+ document . removeEventListener ( 'contentNotEmpty' , contentNotEmpty ) ;
390416
391- if ( timeoutRef ?. current ) {
392- clearTimeout ( timeoutRef . current ) ;
393- }
417+ if ( timeoutRef ?. current ) {
418+ clearTimeout ( timeoutRef . current ) ;
419+ }
394420
395- if ( refreshTokenIntervalRef ?. current ) {
396- clearInterval ( refreshTokenIntervalRef . current ) ;
397- }
421+ if ( refreshTokenIntervalRef ?. current ) {
422+ clearInterval ( refreshTokenIntervalRef . current ) ;
423+ }
398424
399- if ( releaseTimestampIntervalRef ?. current ) {
400- clearInterval ( releaseTimestampIntervalRef . current ) ;
401- }
402- } ;
425+ if ( releaseTimestampIntervalRef ?. current ) {
426+ clearInterval ( releaseTimestampIntervalRef . current ) ;
427+ }
428+ } ;
429+ }
403430 } , [ ] ) ;
404431
405432 useEffect ( ( ) => {
0 commit comments