diff options
| author | Fuwn <[email protected]> | 2026-04-15 01:18:00 +0000 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2026-04-15 01:18:00 +0000 |
| commit | d06a7a9bb689849b2b7beced2606ceb98513f4bb (patch) | |
| tree | 8f54fc3fa12c70b21bf4bf421608c9b9400064da /src/lib/List/Anime | |
| parent | feat(command-palette): add clear anime and manga list caches action (diff) | |
| download | due.moe-d06a7a9bb689849b2b7beced2606ceb98513f4bb.tar.xz due.moe-d06a7a9bb689849b2b7beced2606ceb98513f4bb.zip | |
feat(cache): instant list revalidation from command palette and debug menu
Replaces one-shot boolean revalidateAnime with a counter store so
multiple components can subscribe without race conditions. Adds
revalidateManga store and reactive refresh blocks to DueAnimeList
and MangaListTemplate. Extracts shared invalidateListCaches function
used by both the command palette action and the debug settings button.
Renames palette item to "Refresh" and debug button to "Invalidate".
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> |