diff options
| author | Fuwn <[email protected]> | 2023-09-07 23:11:29 -0700 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2023-09-07 23:11:29 -0700 |
| commit | 21a85d3ffffb615de3b7f8faaaea93f9bf6cd7c2 (patch) | |
| tree | 0a044b34cffbff87f5875af2f0121ea21d5e6a0c /src | |
| parent | feat(media): public media list collection (diff) | |
| download | due.moe-21a85d3ffffb615de3b7f8faaaea93f9bf6cd7c2.tar.xz due.moe-21a85d3ffffb615de3b7f8faaaea93f9bf6cd7c2.zip | |
fix(user): no eager fetch
Diffstat (limited to 'src')
| -rw-r--r-- | src/routes/@[user]/+page.svelte | 50 |
1 files changed, 24 insertions, 26 deletions
diff --git a/src/routes/@[user]/+page.svelte b/src/routes/@[user]/+page.svelte index 758b52e7..1763193a 100644 --- a/src/routes/@[user]/+page.svelte +++ b/src/routes/@[user]/+page.svelte @@ -1,35 +1,21 @@ <script lang="ts"> - import { user } from '$lib/AniList/user'; + import { user, type User } from '$lib/AniList/user'; + import { onMount } from 'svelte'; export let data; + let userData: User | undefined = undefined; + + onMount(() => { + user(data.username).then((profile) => { + userData = profile; + }); + }); + // 8.5827814569536423841e0 </script> -{#await user(data.username)} - Loading ... -{:then profile} - {#if profile === null} - Could not load user profile for <a - href={`https://anilist.co/user/${data.username}`} - target="_blank">@{data.username}</a - >. - - <p /> - - Does this user exist? - {:else} - <a href={`https://anilist.co/user/${profile.name}`} target="_blank" title={String(profile.id)} - >@{profile.name}</a - > - - <p /> - - This user has watched {(profile.statistics.anime.minutesWatched / 60 / 24).toFixed(1)} days of anime - and read - {((profile.statistics.manga.chaptersRead * 8.58) / 60 / 24).toFixed(1)} days of manga. - {/if} -{:catch} +{#if userData === null} Could not load user profile for <a href={`https://anilist.co/user/${data.username}`} target="_blank">@{data.username}</a @@ -38,7 +24,19 @@ <p /> Does this user exist? -{/await} +{:else if userData === undefined} + Loading ... +{:else} + <a href={`https://anilist.co/user/${userData.name}`} target="_blank" title={String(userData.id)} + >@{userData.name}</a + > + + <p /> + + This user has watched {(userData.statistics.anime.minutesWatched / 60 / 24).toFixed(1)} days of anime + and read + {((userData.statistics.manga.chaptersRead * 8.58) / 60 / 24).toFixed(1)} days of manga. +{/if} <p /> |