From d06a7a9bb689849b2b7beced2606ceb98513f4bb Mon Sep 17 00:00:00 2001
From: Fuwn <contact@fuwn.net>
Date: Wed, 15 Apr 2026 01:18:00 +0000
Subject: 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".
---
 src/lib/List/Anime/DueAnimeList.svelte | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

(limited to 'src/lib/List/Anime/DueAnimeList.svelte')

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);
 });
-- 
cgit v1.2.3

