mirror of
https://github.com/jcreek/LivingDexTracker.git
synced 2026-09-17 19:12:03 +00:00
fix(#64): Address PR comments
This commit is contained in:
@@ -24,6 +24,19 @@
|
||||
onMount(async () => {
|
||||
await getUser();
|
||||
|
||||
// Listen for auth state changes to keep the user store in sync
|
||||
const {
|
||||
data: { subscription }
|
||||
} = supabase.auth.onAuthStateChange((event, session) => {
|
||||
console.log('[Layout] Auth state changed:', event, session ? 'Session found' : 'No session');
|
||||
if (session) {
|
||||
localUser = session.user;
|
||||
} else {
|
||||
localUser = null;
|
||||
}
|
||||
user.set(localUser);
|
||||
});
|
||||
|
||||
if (pwaInfo) {
|
||||
const { registerSW } = await import('virtual:pwa-register');
|
||||
registerSW({
|
||||
@@ -41,6 +54,10 @@
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return () => {
|
||||
subscription.unsubscribe();
|
||||
};
|
||||
});
|
||||
|
||||
async function getUser() {
|
||||
|
||||
Reference in New Issue
Block a user