From be9a02cd3cbbda885a478fabd373ed8afff6cc06 Mon Sep 17 00:00:00 2001 From: Fuwn Date: Mon, 6 Nov 2023 10:50:31 -0800 Subject: feat(manga): option to disable volume ood --- src/lib/Media/manga.ts | 46 ++++++++++++++++++++++------------------ src/routes/settings/+page.svelte | 17 +++++++++++++++ src/stores/settings.ts | 4 +++- 3 files changed, 45 insertions(+), 22 deletions(-) (limited to 'src') diff --git a/src/lib/Media/manga.ts b/src/lib/Media/manga.ts index ab33f124..746e9d29 100644 --- a/src/lib/Media/manga.ts +++ b/src/lib/Media/manga.ts @@ -79,32 +79,36 @@ export const chapterCount = async ( } } - const volumeOfChapterData = await ( - await fetch(`/api/mangadex/chapter?id=${mangadexId}&chapter=${manga.mediaListEntry?.progress}`) - ).json(); - let lastAvailableVolume = lastChapterData['data'][0]['attributes']['volume']; - - if (lastAvailableVolume === null) { - let chapterIndex = 0; - - while (chapterIndex < lastChapterData['data'].length && lastAvailableVolume === null) { - if (lastChapterData['data'][chapterIndex]['attributes']['volume'] !== null) { - lastAvailableVolume = lastChapterData['data'][chapterIndex]['attributes']['volume']; + if (!settings.get().disableOutOfDateVolumeWarning) { + const volumeOfChapterData = await ( + await fetch( + `/api/mangadex/chapter?id=${mangadexId}&chapter=${manga.mediaListEntry?.progress}` + ) + ).json(); + let lastAvailableVolume = lastChapterData['data'][0]['attributes']['volume']; + + if (lastAvailableVolume === null) { + let chapterIndex = 0; + + while (chapterIndex < lastChapterData['data'].length && lastAvailableVolume === null) { + if (lastChapterData['data'][chapterIndex]['attributes']['volume'] !== null) { + lastAvailableVolume = lastChapterData['data'][chapterIndex]['attributes']['volume']; + } + + chapterIndex += 1; } - - chapterIndex += 1; } - } - if (volumeOfChapterData['data'] !== undefined && volumeOfChapterData['data'].length > 0) { - const volumeOfChapter = volumeOfChapterData['data'][0]['attributes']['volume']; + if (volumeOfChapterData['data'] !== undefined && volumeOfChapterData['data'].length > 0) { + const volumeOfChapter = volumeOfChapterData['data'][0]['attributes']['volume']; - if (volumeOfChapter !== null) { - completedVolumes = volumeOfChapter; - } + if (volumeOfChapter !== null) { + completedVolumes = volumeOfChapter; + } - if (completedVolumes === volumeOfChapter) { - completedVolumes -= 1; + if (completedVolumes === volumeOfChapter) { + completedVolumes -= 1; + } } } diff --git a/src/routes/settings/+page.svelte b/src/routes/settings/+page.svelte index aafb7853..50c5ac28 100644 --- a/src/routes/settings/+page.svelte +++ b/src/routes/settings/+page.svelte @@ -96,6 +96,23 @@
+ + + Keeping this enabled displays a warning message when there is a mismatch between chapter + progress and the number of volumes you have completed for a given title. (e.g. you are on + Vol. 5 Ch. 50, but only have 3 volumes tracked when you should have 4) + +
+ + Disabling this option speeds up refresh times for manga lists. +
+
+ +
+ Enabling this setting will disable light novel chapter counts and may cause inaccuracy in diff --git a/src/stores/settings.ts b/src/stores/settings.ts index d5a854d6..b6ad02bf 100644 --- a/src/stores/settings.ts +++ b/src/stores/settings.ts @@ -19,6 +19,7 @@ export interface Settings { hoverNavigation: boolean; displayNativeTitles: boolean; guessMethod: 'median' | 'trimmed_mean' | 'weighted_average'; + disableOutOfDateVolumeWarning: boolean; } const defaultSettings: Settings = { @@ -38,7 +39,8 @@ const defaultSettings: Settings = { disableGuessing: false, hoverNavigation: false, displayNativeTitles: false, - guessMethod: 'trimmed_mean' + guessMethod: 'trimmed_mean', + disableOutOfDateVolumeWarning: false }; const createStore = () => { -- cgit v1.2.3