diff options
| author | Fuwn <[email protected]> | 2026-03-22 04:11:30 +0000 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2026-03-22 04:20:41 +0000 |
| commit | ff9dd7da2e15b30cba474f8865d391a21da370aa (patch) | |
| tree | 728fa61ad52211e4bea618067b30005ff6912772 /src/lib | |
| parent | perf: lazy-load authenticated list surfaces (diff) | |
| download | due.moe-ff9dd7da2e15b30cba474f8865d391a21da370aa.tar.xz due.moe-ff9dd7da2e15b30cba474f8865d391a21da370aa.zip | |
perf: fetch dummy media outside the app bundle
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/List/Anime/CompletedAnimeList.svelte | 12 | ||||
| -rw-r--r-- | src/lib/List/Manga/MangaListTemplate.svelte | 17 |
2 files changed, 21 insertions, 8 deletions
diff --git a/src/lib/List/Anime/CompletedAnimeList.svelte b/src/lib/List/Anime/CompletedAnimeList.svelte index 6a393dff..6bfdfdd1 100644 --- a/src/lib/List/Anime/CompletedAnimeList.svelte +++ b/src/lib/List/Anime/CompletedAnimeList.svelte @@ -9,7 +9,6 @@ import AnimeList from "./AnimeListTemplate.svelte"; import { addNotification } from "$lib/Notification/store"; import locale from "$stores/locale"; import identity from "$stores/identity"; -import sampleAnime from "$lib/Data/Static/SampleMedia/anime.json"; export let user: AniListAuthorisation = { accessToken: "", @@ -29,6 +28,10 @@ onMount(async () => { startTime = performance.now(); if (dummy) { + const sampleAnime = (await ( + await fetch("/sample-media/anime.json") + ).json()) as Media[]; + // Use deterministic selection for consistent display const filtered = sampleAnime.filter( (anime) => @@ -44,14 +47,19 @@ onMount(async () => { ); animeLists = Promise.resolve( filtered.slice(0, dummyCount).map((anime, index) => { + const mediaListEntry = + anime.mediaListEntry || + ({ progress: 0 } as NonNullable<Media["mediaListEntry"]>); + anime.status = "FINISHED"; anime.nextAiringEpisode = { airingAt: Math.floor(Date.now() / 1000) + (index + 1) * 24 * 60 * 60, episode: Math.floor((anime.episodes || 12) * 0.8), }; - anime.mediaListEntry.progress = Math.floor( + mediaListEntry.progress = Math.floor( (anime.nextAiringEpisode.episode || 5) * 0.6, ); + anime.mediaListEntry = mediaListEntry; return anime; }) as unknown as Media[], ); diff --git a/src/lib/List/Manga/MangaListTemplate.svelte b/src/lib/List/Manga/MangaListTemplate.svelte index c9f66dd4..eb7ffd83 100644 --- a/src/lib/List/Manga/MangaListTemplate.svelte +++ b/src/lib/List/Manga/MangaListTemplate.svelte @@ -1,5 +1,4 @@ <script lang="ts"> -import sampleManga from "$lib/Data/Static/SampleMedia/manga.json"; import { mediaListCollection, Type, type Media } from "$lib/Data/AniList/media"; import type { AniListAuthorisation } from "$lib/Data/AniList/identity"; import { onDestroy, onMount } from "svelte"; @@ -85,6 +84,10 @@ onMount(async () => { startTime = performance.now(); if (dummy) { + const sampleManga = (await ( + await fetch("/sample-media/manga.json") + ).json()) as Media[]; + // Use deterministic selection for consistent display const filtered = sampleManga.filter( (manga) => @@ -99,12 +102,14 @@ onMount(async () => { ); mangaLists = Promise.resolve( filtered.slice(0, dummyCount).map((manga) => { + const mediaListEntry = + manga.mediaListEntry || + ({ progress: 0 } as NonNullable<Media["mediaListEntry"]>); + manga.status = "FINISHED"; - manga.episodes = Math.floor( - (manga.chapters || 10) * 0.7, - ) as unknown as null; - manga.mediaListEntry.progress = - Math.floor((manga.episodes || 5) * 0.5) + 1; + manga.episodes = Math.floor((manga.chapters || 10) * 0.7); + mediaListEntry.progress = Math.floor((manga.episodes || 5) * 0.5) + 1; + manga.mediaListEntry = mediaListEntry; return manga; }) as unknown as Media[], ); |