You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

36 lines
1.0 KiB

<script lang="ts">
import '../app.css';
import { sessionManager } from '../lib/services/auth/session-manager.js';
import { onMount } from 'svelte';
import { browser } from '$app/environment';
// Restore session immediately if in browser (before onMount)
if (browser) {
// Try to restore session synchronously if possible
// This ensures session is restored before any components render
(async () => {
try {
if (!sessionManager.isLoggedIn()) {
await sessionManager.restoreSession();
}
} catch (error) {
console.error('Failed to restore session:', error);
}
})();
}
// Also restore in onMount as fallback
onMount(async () => {
try {
// Only restore if there's no active session
// This prevents overwriting sessions that were just created during login
if (!sessionManager.isLoggedIn()) {
await sessionManager.restoreSession();
}
} catch (error) {
console.error('Failed to restore session:', error);
}
});
</script>
<slot />