···22import { browser } from '$app/environment';
33import { goto } from '$app/navigation';
4455+// Using Svelte 5 state
56let user = $state({
67 selectedLanguages: [],
78 translators: ['deepl'], // Default to deepl, can support others in future
···1213 username: null
1314 },
1415 syncing: false
1616+});
1717+1818+// Make the auth state reactive for components
1919+$effect(() => {
2020+ // This effect will run when any property of user.auth changes
2121+ // Just accessing the properties to trigger the effect when they change
2222+ const { isAuthenticated, id, email, username } = user.auth;
1523});
16241725// Load from localStorage on module load
···215223 await translationHistoryStore.loadFromDatabase();
216224 }
217225226226+ // Add a small delay to ensure the UI updates before navigation
227227+ await new Promise(resolve => setTimeout(resolve, 10));
228228+218229 // Redirect to translate page
219219- goto('/');
230230+ goto('/', { replaceState: true });
220231221232 return { success: true };
222233 } catch (error) {
···251262 translationHistoryStore.clearHistory();
252263 }
253264254254- // Redirect to home page after logout
255255- goto('/');
265265+ // Add a small delay to ensure the UI updates before navigation
266266+ await new Promise(resolve => setTimeout(resolve, 10));
267267+268268+ // Redirect to home page after logout, using replaceState to prevent navigation issues
269269+ goto('/', { replaceState: true });
256270257271 return { success: true };
258272 } catch (error) {