INTERVAL_REFRESH_MS

This commit is contained in:
Igor Loskutov
2025-09-04 19:39:55 -04:00
parent e9318708e1
commit cacdcbfba2

View File

@@ -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]);