ui frotneedn fixes

This commit is contained in:
IGNY8 VPS (Salman)
2025-11-26 06:47:23 +00:00
parent 451594bd29
commit 4fe68cc271
40 changed files with 1638 additions and 275 deletions

View File

@@ -194,13 +194,29 @@ const LayoutContent: React.FC = () => {
refreshUserData();
};
// Periodic refresh every 2 minutes
// Proactive token refresh - refresh token every 12 minutes (before 15-minute expiry)
// This prevents 401 errors and ensures seamless user experience
const tokenRefreshInterval = setInterval(async () => {
const authState = useAuthStore.getState();
const refreshToken = authState?.refreshToken;
if (refreshToken && authState?.isAuthenticated) {
try {
await authState.refreshToken();
console.debug('Token proactively refreshed');
} catch (error) {
console.debug('Proactive token refresh failed (will retry on next API call):', error);
}
}
}, 720000); // 12 minutes = 720000ms
// Periodic user data refresh every 2 minutes
const intervalId = setInterval(() => refreshUserData(), 120000);
document.addEventListener('visibilitychange', handleVisibilityChange);
window.addEventListener('focus', handleFocus);
return () => {
clearInterval(tokenRefreshInterval);
clearInterval(intervalId);
document.removeEventListener('visibilitychange', handleVisibilityChange);
window.removeEventListener('focus', handleFocus);