From 08641a3f6f1d95cc8d8dbfeebdecf6c0d2a2b0a6 Mon Sep 17 00:00:00 2001 From: Fuwn Date: Thu, 21 May 2026 13:44:46 +0000 Subject: feat(debug): add dry-run mutations mode New 'Dry-run mutations' toggle in the Debug settings panel blocks outgoing list updates (the + button) and skips the post-mutation refresh so optimistic UI changes persist locally for testing. The mutation gate sits in incrementMediaProgress; CleanAnimeList only revalidates when the request actually went out. --- src/lib/Media/Anime/cache.ts | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'src/lib/Media/Anime') diff --git a/src/lib/Media/Anime/cache.ts b/src/lib/Media/Anime/cache.ts index e988f255..e1a711ca 100644 --- a/src/lib/Media/Anime/cache.ts +++ b/src/lib/Media/Anime/cache.ts @@ -2,6 +2,7 @@ import { get } from "svelte/store"; import anime from "$stores/anime"; import { mediaListCollection, Type } from "../../Data/AniList/media"; import lastPruneTimes from "$stores/lastPruneTimes"; +import settings from "$stores/settings"; import type { AniListAuthorisation, UserIdentity, @@ -26,8 +27,19 @@ export const incrementMediaProgress = ( id: number, progress: number | undefined, user: AniListAuthorisation, - callback: () => void, + callback: (skipped?: boolean) => void, ) => { + if (get(settings).debugDryRunMutations) { + console.log( + `[dry-run] SaveMediaListEntry(mediaId: ${id}, progress: ${ + (progress || 0) + 1 + }) skipped`, + ); + callback(true); + + return; + } + fetch("https://graphql.anilist.co", { method: "POST", headers: { @@ -40,5 +52,5 @@ export const incrementMediaProgress = ( (progress || 0) + 1 }) { id } }`, }), - }).then(callback); + }).then(() => callback(false)); }; -- cgit v1.2.3