mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-21 09:11:12 -05:00
feat: Add diagnostic logging for tab focus issue
This commit is contained in:
@@ -335,16 +335,24 @@ function AuthProviderComponent({ children }: { children: React.ReactNode }) {
|
||||
|
||||
// Handle page visibility changes - only verify if inactive for >5 minutes
|
||||
const handleVisibilityChange = () => {
|
||||
const timeSinceLastCheck = Date.now() - lastVisibilityVerificationRef.current;
|
||||
const FIVE_MINUTES = 5 * 60 * 1000;
|
||||
|
||||
console.log('🔐 [AUTH] Visibility changed', {
|
||||
state: document.visibilityState,
|
||||
timeSinceLastCheck: Math.round(timeSinceLastCheck / 1000) + 's',
|
||||
willVerifySession: document.visibilityState === 'visible' && timeSinceLastCheck > FIVE_MINUTES
|
||||
});
|
||||
|
||||
if (document.visibilityState === 'visible') {
|
||||
const timeSinceLastCheck = Date.now() - lastVisibilityVerificationRef.current;
|
||||
const FIVE_MINUTES = 5 * 60 * 1000;
|
||||
|
||||
if (timeSinceLastCheck > FIVE_MINUTES) {
|
||||
authLog('[Auth] Tab visible after 5+ minutes, verifying session');
|
||||
console.log(' ⚠️ Verifying session - this may cause component re-renders');
|
||||
lastVisibilityVerificationRef.current = Date.now();
|
||||
verifySession();
|
||||
} else {
|
||||
authLog('[Auth] Tab visible, session recently verified, skipping');
|
||||
console.log(' ✅ Session recently verified, skipping verification');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user