diff options
| author | Fuwn <[email protected]> | 2024-05-06 05:02:49 -0700 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2024-05-06 05:02:49 -0700 |
| commit | 4127ccb975dc88ac79cd1d82f2563f771fc0740f (patch) | |
| tree | f9cbcaa51272b8acb590bedbd954ae7c424195e8 /src/lib/List/Anime/CompletedAnimeList.svelte | |
| parent | fix(badge.css): remove button styling (diff) | |
| download | due.moe-4127ccb975dc88ac79cd1d82f2563f771fc0740f.tar.xz due.moe-4127ccb975dc88ac79cd1d82f2563f771fc0740f.zip | |
feat(landing): cover mode list demos
Diffstat (limited to 'src/lib/List/Anime/CompletedAnimeList.svelte')
| -rw-r--r-- | src/lib/List/Anime/CompletedAnimeList.svelte | 45 |
1 files changed, 41 insertions, 4 deletions
diff --git a/src/lib/List/Anime/CompletedAnimeList.svelte b/src/lib/List/Anime/CompletedAnimeList.svelte index 70dae576..67e917b6 100644 --- a/src/lib/List/Anime/CompletedAnimeList.svelte +++ b/src/lib/List/Anime/CompletedAnimeList.svelte @@ -9,8 +9,15 @@ import { getNotificationsContext } from 'svelte-notifications'; import locale from '$stores/locale'; import identity from '$stores/identity'; + import sampleAnime from '$lib/Data/Static/SampleMedia/anime.json'; - export let user: AniListAuthorisation; + export let user: AniListAuthorisation = { + accessToken: '', + refreshToken: '', + expiresIn: 0, + tokenType: '' + }; + export let dummy = false; const { addNotification } = getNotificationsContext(); let animeLists: Promise<Media[]>; @@ -19,12 +26,41 @@ onMount(async () => { startTime = performance.now(); - animeLists = mediaListCollection(user, $identity, Type.Anime, $anime, $lastPruneTimes.anime, { - addNotification - }); + + if (dummy) { + animeLists = Promise.resolve( + sampleAnime + .filter( + (anime) => + anime.episodes && + !anime.tags.some((tag) => tag.name === 'Nudity') && + !anime.tags.some((tag) => tag.name === 'Rape') && + !anime.tags.some((tag) => tag.name === 'Tragedy') && + !anime.tags.some((tag) => tag.name === 'Bondage') && + !anime.genres.some((genre) => genre === 'Hentai') && + anime.genres.some((genre) => genre === 'Comedy') && + anime.status !== 'NOT_YET_RELEASED' && + anime.episodes > 1 + ) + .sort(() => 0.5 - Math.random()) + .map((anime) => { + anime.mediaListEntry.progress = Math.floor(Math.random() * (anime.episodes || 0)) + 1; + anime.status = 'FINISHED'; + + return anime; + }) + .slice(0, 7) as unknown as Media[] + ); + } else { + animeLists = mediaListCollection(user, $identity, Type.Anime, $anime, $lastPruneTimes.anime, { + addNotification + }); + } }); const cleanMedia = (anime: Media[]) => { + if (anime && dummy) return anime; + if (anime === undefined) return []; const outdatedCompletedAnime = anime.filter( @@ -56,4 +92,5 @@ {user} title={$locale().lists.completed.anime} completed + {dummy} /> |