fix(pwa): add visibilitychange listener for Android sleep issues
This commit is contained in:
@@ -54,6 +54,15 @@ export default function Home() {
|
||||
|
||||
checkUser();
|
||||
|
||||
// Listen for visibility change (wake up from sleep)
|
||||
const handleVisibilityChange = () => {
|
||||
if (document.visibilityState === 'visible') {
|
||||
console.log('[Auth] App became visible, refreshing session...');
|
||||
checkUser();
|
||||
}
|
||||
};
|
||||
document.addEventListener('visibilitychange', handleVisibilityChange);
|
||||
|
||||
// Listen for auth changes
|
||||
const { data: { subscription } } = supabase.auth.onAuthStateChange((event, session) => {
|
||||
console.log('[Auth] State change event:', event, {
|
||||
@@ -72,7 +81,10 @@ export default function Home() {
|
||||
}
|
||||
});
|
||||
|
||||
return () => subscription.unsubscribe();
|
||||
return () => {
|
||||
subscription.unsubscribe();
|
||||
document.removeEventListener('visibilitychange', handleVisibilityChange);
|
||||
};
|
||||
}, []);
|
||||
|
||||
const fetchCollection = async () => {
|
||||
|
||||
Reference in New Issue
Block a user