diff options
| -rw-r--r-- | src/routes/+layout.svelte | 25 | ||||
| -rw-r--r-- | src/stores/identity.ts | 2 |
2 files changed, 21 insertions, 6 deletions
diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte index a9c294c2..a1e9ef4b 100644 --- a/src/routes/+layout.svelte +++ b/src/routes/+layout.svelte @@ -45,6 +45,13 @@ ? 200 : -200; + $: { + if (data.user !== undefined) + getUserIdentity(data.user).then((h) => { + if ($userIdentity.id === -2) userIdentity.set(h); + }); + } + onMount(async () => { if (browser && localStorage.getItem('redirect')) { window.location.href = localStorage.getItem('redirect') ?? '/'; @@ -53,10 +60,6 @@ } settings.get(); - - if (data.user !== undefined) { - if ($userIdentity.id === -1) userIdentity.set(await getUserIdentity(data.user)); - } }); </script> @@ -98,7 +101,19 @@ {$locale().navigation.logIn} </a> {:else} - <a href={root('/api/authentication/log-out')} class="header-item"> + <a + href={'#'} + class="header-item" + on:click={() => { + userIdentity.set({ + id: -2, + name: '', + avatar: 'https://s4.anilist.co/file/anilistcdn/user/avatar/large/default.png' + }); + + window.location.href = root('/api/authentication/log-out'); + }} + > {$locale().navigation.logOut} </a> {#if data.user} diff --git a/src/stores/identity.ts b/src/stores/identity.ts index 765ce5b2..5229c4cd 100644 --- a/src/stores/identity.ts +++ b/src/stores/identity.ts @@ -4,7 +4,7 @@ import { writable } from 'svelte/store'; const defaultIdentity: UserIdentity = { name: '', - id: -1, + id: -2, avatar: 'https://s4.anilist.co/file/anilistcdn/user/avatar/large/default.png' }; |