From 178267e2b0456f6d1ff4c156323da551e274f1a8 Mon Sep 17 00:00:00 2001 From: Fuwn Date: Thu, 9 May 2024 21:54:06 -0700 Subject: feat(welcome): add upcoming times --- src/lib/List/Anime/CleanAnimeList.svelte | 4 +++- src/lib/List/Anime/CompletedAnimeList.svelte | 14 +++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) (limited to 'src/lib') diff --git a/src/lib/List/Anime/CleanAnimeList.svelte b/src/lib/List/Anime/CleanAnimeList.svelte index 175b138c..f36bb8d0 100644 --- a/src/lib/List/Anime/CleanAnimeList.svelte +++ b/src/lib/List/Anime/CleanAnimeList.svelte @@ -36,6 +36,8 @@ let keyCacher: NodeJS.Timeout; onMount(() => { + if (dummy) return; + keyCacher = setInterval( () => { media = media; @@ -150,7 +152,7 @@ } }}>+ - {#if !completed} + {#if !completed || dummy} [{anime.nextAiringEpisode?.episode === -1 ? '?' : (anime.nextAiringEpisode?.episode || 1) - 1}] diff --git a/src/lib/List/Anime/CompletedAnimeList.svelte b/src/lib/List/Anime/CompletedAnimeList.svelte index 67e917b6..29d62724 100644 --- a/src/lib/List/Anime/CompletedAnimeList.svelte +++ b/src/lib/List/Anime/CompletedAnimeList.svelte @@ -44,11 +44,23 @@ ) .sort(() => 0.5 - Math.random()) .map((anime) => { - anime.mediaListEntry.progress = Math.floor(Math.random() * (anime.episodes || 0)) + 1; + const nextEpisode = Math.floor(Math.random() * (anime.episodes || 0)) + 1 || 1; + anime.status = 'FINISHED'; + anime.nextAiringEpisode = { + airingAt: + Math.floor(Date.now() / 1000) + + Math.floor(Math.random() * 7 * 24 * 60 * 60) + + 60 * 60, + episode: Math.floor(Math.random() * (anime.episodes || 0)) + 1 || 1 + }; + anime.mediaListEntry.progress = Math.floor(Math.random() * nextEpisode) || 1; return anime; }) + .sort( + (a, b) => (a.nextAiringEpisode?.airingAt || 0) - (b.nextAiringEpisode?.airingAt || 0) + ) .slice(0, 7) as unknown as Media[] ); } else { -- cgit v1.2.3