aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/lib/List/Anime/CleanAnimeList.svelte14
-rw-r--r--src/lib/Locale/english.ts4
-rw-r--r--src/lib/Locale/japanese.ts4
-rw-r--r--src/lib/Locale/layout.ts4
-rw-r--r--src/lib/Media/Anime/cache.ts16
-rw-r--r--src/lib/Settings/Categories/Debug.svelte7
-rw-r--r--src/stores/settings.ts2
7 files changed, 45 insertions, 6 deletions
diff --git a/src/lib/List/Anime/CleanAnimeList.svelte b/src/lib/List/Anime/CleanAnimeList.svelte
index 3f397c25..42f4d933 100644
--- a/src/lib/List/Anime/CleanAnimeList.svelte
+++ b/src/lib/List/Anime/CleanAnimeList.svelte
@@ -224,10 +224,16 @@ const increment = (anime: Media, progress: number) => {
? media.filter((m) => m.id !== anime.id)
: media;
- incrementMediaProgress(anime.id, anime.mediaListEntry?.progress, user, () => {
- pendingUpdate = null;
- $revalidateAnime = $revalidateAnime + 1;
- });
+ incrementMediaProgress(
+ anime.id,
+ anime.mediaListEntry?.progress,
+ user,
+ (skipped) => {
+ pendingUpdate = null;
+
+ if (!skipped) $revalidateAnime = $revalidateAnime + 1;
+ },
+ );
};
</script>
diff --git a/src/lib/Locale/english.ts b/src/lib/Locale/english.ts
index 0cfc4035..f0195948 100644
--- a/src/lib/Locale/english.ts
+++ b/src/lib/Locale/english.ts
@@ -284,6 +284,10 @@ const English: Locale = {
"If you are having issues with data loading or logging out, it is recommended to clear your site data.",
},
dummyLists: "Use dummy media lists",
+ dryRunMutations: {
+ title: "Dry-run mutations",
+ hint: "Block outgoing list updates (e.g., the + button) and skip the post-mutation refresh so optimistic UI changes persist locally for testing. No data is sent to AniList.",
+ },
},
hololive: {
live: "LIVE",
diff --git a/src/lib/Locale/japanese.ts b/src/lib/Locale/japanese.ts
index af309a25..8e3744d4 100644
--- a/src/lib/Locale/japanese.ts
+++ b/src/lib/Locale/japanese.ts
@@ -284,6 +284,10 @@ const Japanese: Locale = {
"データの読み込みやログアウトに問題がある場合、サイトデータをクリアすることをお勧めします。",
},
dummyLists: "ダミーメディアリストを使用する",
+ dryRunMutations: {
+ title: "ドライランモード",
+ hint: "リストの更新リクエスト(+ボタンなど)の送信をブロックし、更新後の再取得もスキップします。楽観的UIの変更をローカルで保持してテストできます。AniListにはデータは送信されません。",
+ },
},
hololive: {
live: "ライブ",
diff --git a/src/lib/Locale/layout.ts b/src/lib/Locale/layout.ts
index f317ab7f..697404f2 100644
--- a/src/lib/Locale/layout.ts
+++ b/src/lib/Locale/layout.ts
@@ -282,6 +282,10 @@ export interface Locale {
hint2: LocaleValue;
};
dummyLists: LocaleValue;
+ dryRunMutations: {
+ title: LocaleValue;
+ hint: LocaleValue;
+ };
};
hololive: {
live: LocaleValue;
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));
};
diff --git a/src/lib/Settings/Categories/Debug.svelte b/src/lib/Settings/Categories/Debug.svelte
index ad388fee..6da4b6ae 100644
--- a/src/lib/Settings/Categories/Debug.svelte
+++ b/src/lib/Settings/Categories/Debug.svelte
@@ -15,6 +15,13 @@ import { invalidateListCaches } from "$lib/Media/invalidate";
setting="debugShowListTimings"
text={$locale().debug.showListTimings}
/>
+<SettingCheckboxToggle
+ setting="debugDryRunMutations"
+ text={$locale().debug.dryRunMutations.title}
+/>
+<SettingHint lineBreak>
+ {$locale().debug.dryRunMutations.hint}
+</SettingHint>
<br />
<button onclick={invalidateListCaches}>{$locale().debug.clearCaches}</button>
diff --git a/src/stores/settings.ts b/src/stores/settings.ts
index 24d9eef0..1d808a82 100644
--- a/src/stores/settings.ts
+++ b/src/stores/settings.ts
@@ -71,6 +71,7 @@ export interface Settings {
displayDataSaver: boolean;
debugDummyLists: boolean;
debugShowListTimings: boolean;
+ debugDryRunMutations: boolean;
displayScheduleFilterList: boolean;
displayReverseSort: boolean;
displayAnimeSort: "difference" | "start_date" | "end_date" | "time_remaining";
@@ -128,6 +129,7 @@ const defaultSettings: Settings = {
// Debug
debugDummyLists: false,
debugShowListTimings: false,
+ debugDryRunMutations: false,
// Calculation
calculateChaptersRoundedDown: true,