@@ -21,9 +21,9 @@ function App() {
2121 localStorageKeys . FALLBACK_IMAGE
2222 ) ;
2323
24- const loginCheckTimeout = 15 * 1000 ;
25- const refreshTimeout = 60 * 1000 ;
26- const releaseTimestampIntervalTimeout = 1000 * 60 * 5 ;
24+ const loginCheckTimeoutDefault = 20 * 1000 ;
25+ const refreshTokenTimeoutDefault = 60 * 1000 * 15 ;
26+ const releaseTimestampIntervalTimeoutDefault = 1000 * 60 * 10 ;
2727
2828 const [ running , setRunning ] = useState ( false ) ;
2929 const [ screen , setScreen ] = useState ( '' ) ;
@@ -97,7 +97,7 @@ function App() {
9797 Logger . log ( 'info' , 'Refreshing token.' ) ;
9898
9999 ConfigLoader . loadConfig ( ) . then ( ( config ) => {
100- fetch ( config . authenticationRefreshTokenEndpoint , {
100+ fetch ( ` ${ config . apiEndpoint } /v2/authentication/token/refresh` , {
101101 method : 'POST' ,
102102 headers : {
103103 'Content-Type' : 'application/json' ,
@@ -168,8 +168,13 @@ function App() {
168168 } )
169169 ) ;
170170
171- // Start refresh token interval.
172- refreshTokenIntervalRef . current = setInterval ( checkToken , refreshTimeout ) ;
171+ ConfigLoader . loadConfig ( ) . then ( ( config ) => {
172+ // Start refresh token interval.
173+ refreshTokenIntervalRef . current = setInterval (
174+ checkToken ,
175+ config . refreshTokenTimeout ?? refreshTokenTimeoutDefault
176+ ) ;
177+ } ) ;
173178 } ;
174179
175180 const checkLogin = ( ) => {
@@ -182,7 +187,7 @@ function App() {
182187 startContent ( localScreenId ) ;
183188 } else {
184189 ConfigLoader . loadConfig ( ) . then ( ( config ) => {
185- fetch ( config . authenticationEndpoint , {
190+ fetch ( ` ${ config . apiEndpoint } /v2/authentication/screen` , {
186191 method : 'POST' ,
187192 mode : 'cors' ,
188193 credentials : 'include' ,
@@ -225,15 +230,21 @@ function App() {
225230 clearTimeout ( timeoutRef . current ) ;
226231 }
227232
228- timeoutRef . current = setTimeout ( checkLogin , loginCheckTimeout ) ;
233+ timeoutRef . current = setTimeout (
234+ checkLogin ,
235+ config . loginCheckTimeout ?? loginCheckTimeoutDefault
236+ ) ;
229237 }
230238 } )
231239 . catch ( ( ) => {
232240 if ( timeoutRef . current !== null ) {
233241 clearTimeout ( timeoutRef . current ) ;
234242 }
235243
236- timeoutRef . current = setTimeout ( checkLogin , loginCheckTimeout ) ;
244+ timeoutRef . current = setTimeout (
245+ checkLogin ,
246+ config . loginCheckTimeout ?? loginCheckTimeoutDefault
247+ ) ;
237248 } ) ;
238249 } ) ;
239250 }
@@ -331,10 +342,13 @@ function App() {
331342
332343 checkForUpdates ( ) ;
333344
334- releaseTimestampIntervalRef . current = setInterval (
335- checkForUpdates ,
336- releaseTimestampIntervalTimeout
337- ) ;
345+ ConfigLoader . loadConfig ( ) . then ( ( config ) => {
346+ releaseTimestampIntervalRef . current = setInterval (
347+ checkForUpdates ,
348+ config . releaseTimestampIntervalTimeout ??
349+ releaseTimestampIntervalTimeoutDefault
350+ ) ;
351+ } ) ;
338352
339353 return function cleanup ( ) {
340354 Logger . log ( 'info' , 'Unmounting App.' ) ;
@@ -361,7 +375,7 @@ function App() {
361375
362376 useEffect ( ( ) => {
363377 // Append screenId to current url for easier debugging. If errors are logged in the API's standard http log this
364- // makes it easy to see what screen client has made the http call by putting the screen id in the referer http
378+ // makes it easy to see what screen client has made the http call by putting the screen id in the referer http
365379 // header.
366380 if ( screen && screen [ '@id' ] ) {
367381 const url = new URL ( window . location . href ) ;
0 commit comments