diff options
| author | Fuwn <[email protected]> | 2023-08-27 15:52:22 -0700 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2023-08-27 15:52:22 -0700 |
| commit | c00e893e2f178d51bc18fdb5c10dcf46a3cef1d3 (patch) | |
| tree | f557e3f4fb71bd8e3a385ff0ec3a3845c2b481e4 /src/routes | |
| parent | feat(layout): username loading (diff) | |
| download | due.moe-c00e893e2f178d51bc18fdb5c10dcf46a3cef1d3.tar.xz due.moe-c00e893e2f178d51bc18fdb5c10dcf46a3cef1d3.zip | |
feat(layout): cache user identity
Diffstat (limited to 'src/routes')
| -rw-r--r-- | src/routes/+layout.svelte | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte index 01ede9e0..07c5435a 100644 --- a/src/routes/+layout.svelte +++ b/src/routes/+layout.svelte @@ -1,8 +1,9 @@ <script> import { env } from '$env/dynamic/public'; - import { userIdentity } from '$lib/AniList/identity'; + import { userIdentity as getUserIdentity } from '$lib/AniList/identity'; import { onMount } from 'svelte'; import { lastActivityDate } from '$lib/AniList/activity'; + import userIdentity from '../stores/userIdentity'; export let data; @@ -11,8 +12,12 @@ onMount(async () => { if (data.user !== undefined) { - currentUserIdentity = await userIdentity(data.user); - currentUserIdentity.name = `${currentUserIdentity.name}`; + if ($userIdentity === '') { + userIdentity.set(JSON.stringify(await getUserIdentity(data.user))); + } + + currentUserIdentity = JSON.parse($userIdentity); + currentUserIdentity.name = currentUserIdentity.name; lastActivityWasToday = (await lastActivityDate(currentUserIdentity)).toDateString() === new Date().toDateString(); } |