aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFuwn <[email protected]>2024-01-30 21:57:24 -0800
committerFuwn <[email protected]>2024-01-30 21:57:24 -0800
commit1949157d2aec0a6228f54bd64cc4024851842000 (patch)
tree315465c1cfea4b91352a4bac1035887f91712c94 /src
parentrefactor(anime): global subsPlease cache (diff)
downloaddue.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.svelte16
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 />