diff options
| author | Fuwn <[email protected]> | 2026-04-14 18:19:54 -0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2026-04-14 18:19:54 -0700 |
| commit | f3ac4e6051d5b18c26d5a876ce12ddd1fd0f7107 (patch) | |
| tree | 8f54fc3fa12c70b21bf4bf421608c9b9400064da /src/lib/List/Anime | |
| parent | fix(ui): balance homepage media panels (diff) | |
| parent | feat(cache): instant list revalidation from command palette and debug menu (diff) | |
| download | due.moe-f3ac4e6051d5b18c26d5a876ce12ddd1fd0f7107.tar.xz due.moe-f3ac4e6051d5b18c26d5a876ce12ddd1fd0f7107.zip | |
Merge pull request #3 from Fuwn/feat/instant-cache-invalidation
feat(cache): instant list revalidation from command palette and debug menu
Diffstat (limited to 'src/lib/List/Anime')
| -rw-r--r-- | src/lib/List/Anime/CleanAnimeList.svelte | 2 | ||||
| -rw-r--r-- | src/lib/List/Anime/DueAnimeList.svelte | 22 | ||||
| -rw-r--r-- | src/lib/List/Anime/UpcomingAnimeList.svelte | 36 |
3 files changed, 43 insertions, 17 deletions
diff --git a/src/lib/List/Anime/CleanAnimeList.svelte b/src/lib/List/Anime/CleanAnimeList.svelte index 808a8e5b..35a12314 100644 --- a/src/lib/List/Anime/CleanAnimeList.svelte +++ b/src/lib/List/Anime/CleanAnimeList.svelte @@ -193,7 +193,7 @@ onDestroy(() => clearAiringRefreshTimeout()); const increment = (anime: Media, progress: number) => { if (!dummy && pendingUpdate !== anime.id) { - $revalidateAnime = true; + $revalidateAnime = $revalidateAnime + 1; lastUpdatedMedia = anime.id; pendingUpdate = anime.id; diff --git a/src/lib/List/Anime/DueAnimeList.svelte b/src/lib/List/Anime/DueAnimeList.svelte index 2c707ffb..d2c47ebe 100644 --- a/src/lib/List/Anime/DueAnimeList.svelte +++ b/src/lib/List/Anime/DueAnimeList.svelte @@ -16,6 +16,7 @@ import { import { addNotification } from "$lib/Notification/store"; import locale from "$stores/locale"; import identity from "$stores/identity"; +import revalidateAnime from "$stores/revalidateAnime"; export let user: AniListAuthorisation; let animeLists: Promise<Media[]>; @@ -68,6 +69,27 @@ onMount(async () => { $: if (keyCacher && keyCacheMinutes !== $settings.cacheMinutes) restartKeyCacher($settings.cacheMinutes); +let lastAnimeRevalidation = 0; + +$: if ($revalidateAnime > lastAnimeRevalidation) { + lastAnimeRevalidation = $revalidateAnime; + + startTime = performance.now(); + endTime = -1; + + animeLists = mediaListCollection( + user, + $identity, + Type.Anime, + $anime, + $lastPruneTimes.anime, + { + forcePrune: true, + addNotification, + }, + ); +} + onDestroy(() => { if (keyCacher) clearInterval(keyCacher); }); diff --git a/src/lib/List/Anime/UpcomingAnimeList.svelte b/src/lib/List/Anime/UpcomingAnimeList.svelte index d9b91122..ed47f22f 100644 --- a/src/lib/List/Anime/UpcomingAnimeList.svelte +++ b/src/lib/List/Anime/UpcomingAnimeList.svelte @@ -96,22 +96,26 @@ const cleanMedia = ( return upcomingAnime; }; -$: { - if ($revalidateAnime) { - $revalidateAnime = false; - $lastPruneTimes.anime = -1; - animeLists = mediaListCollection( - user, - $identity, - Type.Anime, - $anime, - $lastPruneTimes.anime, - { - addNotification, - notificationType: "Upcoming Episodes", - }, - ); - } +let lastAnimeRevalidation = 0; + +$: if ($revalidateAnime > lastAnimeRevalidation) { + lastAnimeRevalidation = $revalidateAnime; + + startTime = performance.now(); + endTime = -1; + + animeLists = mediaListCollection( + user, + $identity, + Type.Anime, + $anime, + $lastPruneTimes.anime, + { + forcePrune: true, + addNotification, + notificationType: "Upcoming Episodes", + }, + ); } </script> |