mirror of
https://github.com/Monadical-SAS/reflector.git
synced 2025-12-20 12:19:06 +00:00
INTERVAL_REFRESH_MS
This commit is contained in:
@@ -19,6 +19,9 @@ export function SessionAutoRefresh({ children }) {
|
|||||||
auth.status === "authenticated" ? auth.accessTokenExpires : null;
|
auth.status === "authenticated" ? auth.accessTokenExpires : null;
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
// technical value for how often the setInterval will be polling news - not too fast (no spam in case of errors)
|
||||||
|
// and not too slow (debuggable)
|
||||||
|
const INTERVAL_REFRESH_MS = 5000;
|
||||||
const interval = setInterval(() => {
|
const interval = setInterval(() => {
|
||||||
if (accessTokenExpires !== null) {
|
if (accessTokenExpires !== null) {
|
||||||
const timeLeft = accessTokenExpires - Date.now();
|
const timeLeft = accessTokenExpires - Date.now();
|
||||||
@@ -32,7 +35,7 @@ export function SessionAutoRefresh({ children }) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, 5000);
|
}, INTERVAL_REFRESH_MS);
|
||||||
|
|
||||||
return () => clearInterval(interval);
|
return () => clearInterval(interval);
|
||||||
}, [accessTokenExpires, auth.update]);
|
}, [accessTokenExpires, auth.update]);
|
||||||
|
|||||||
Reference in New Issue
Block a user