diff options
| author | Fuwn <[email protected]> | 2024-01-30 21:57:24 -0800 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2024-01-30 21:57:24 -0800 |
| commit | 1949157d2aec0a6228f54bd64cc4024851842000 (patch) | |
| tree | 315465c1cfea4b91352a4bac1035887f91712c94 /src | |
| parent | refactor(anime): global subsPlease cache (diff) | |
| download | due.moe-1949157d2aec0a6228f54bd64cc4024851842000.tar.xz due.moe-1949157d2aec0a6228f54bd64cc4024851842000.zip | |
feat(layout): only load subtitles when needed
Diffstat (limited to 'src')
| -rw-r--r-- | src/routes/+layout.svelte | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte index ab9bd40a..37c65154 100644 --- a/src/routes/+layout.svelte +++ b/src/routes/+layout.svelte @@ -69,16 +69,14 @@ getUserIdentity(data.user).then((h) => { if ($userIdentity.id === -2) userIdentity.set(h); }); - - if (!$subsPlease) - subsPlease.set( - await ( - await fetch( - root(`/api/subsplease?tz=${Intl.DateTimeFormat().resolvedOptions().timeZone}`) - ) - ).json() - ); }); + + $: { + if (data.url === '/' && !$subsPlease) + fetch(root(`/api/subsplease?tz=${Intl.DateTimeFormat().resolvedOptions().timeZone}`)) + .then((r) => r.json()) + .then((r) => subsPlease.set(r)); + } </script> <HeadTitle /> |