From 0b957291eb52a31c5b96ec92dab5bbb64125291a Mon Sep 17 00:00:00 2001 From: Fuwn Date: Fri, 1 Sep 2023 00:08:40 -0700 Subject: fix(due): better increment follow-up --- src/lib/AniList/media.ts | 6 ++++-- src/lib/List/Due/AnimeList.svelte | 5 +---- src/lib/List/Due/MangaList.svelte | 9 ++++----- 3 files changed, 9 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/lib/AniList/media.ts b/src/lib/AniList/media.ts index 36f042e9..3827feae 100644 --- a/src/lib/AniList/media.ts +++ b/src/lib/AniList/media.ts @@ -58,7 +58,8 @@ export const mediaListCollection = async ( userIdentity: UserIdentity, type: Type, mediaCache: string | undefined, - currentLastPruneAt: string | number = 0 + currentLastPruneAt: string | number, + forcePrune: boolean = false ) => { let currentCacheMinutes; @@ -75,7 +76,8 @@ export const mediaListCollection = async ( } else { if ( (new Date().getTime() - Number(currentLastPruneAt)) / 1000 / 60 > - Number(currentCacheMinutes) + Number(currentCacheMinutes) || + forcePrune ) { if (type === Type.Anime) { animeLastPrune.set(new Date().getTime().toString()); diff --git a/src/lib/List/Due/AnimeList.svelte b/src/lib/List/Due/AnimeList.svelte index 39916f19..4257c922 100644 --- a/src/lib/List/Due/AnimeList.svelte +++ b/src/lib/List/Due/AnimeList.svelte @@ -121,10 +121,7 @@ }; const updateMedia = async (id: number, progress: number | undefined) => { - anime.set(''); - animeLastPrune.set('1'); - - animeLists = mediaListCollection(user, identity, Type.Anime, $anime, $animeLastPrune); + animeLists = mediaListCollection(user, identity, Type.Anime, $anime, $animeLastPrune, true); await fetch(`/anilist/increment?id=${id}&progress=${progress! + 1}`); }; diff --git a/src/lib/List/Due/MangaList.svelte b/src/lib/List/Due/MangaList.svelte index e6d82547..57b6a5b1 100644 --- a/src/lib/List/Due/MangaList.svelte +++ b/src/lib/List/Due/MangaList.svelte @@ -93,12 +93,11 @@ }; const updateMedia = async (id: number, progress: number | undefined) => { - manga.set(''); - chapterDatabase.chapters.delete(id).then(async () => { - mangaLists = mediaListCollection(user, identity, Type.Manga, $manga, $mangaLastPrune); + await chapterDatabase.chapters.delete(id); - await fetch(`/anilist/increment?id=${id}&progress=${progress! + 1}`); - }); + mangaLists = mediaListCollection(user, identity, Type.Manga, $manga, $mangaLastPrune, true); + + await fetch(`/anilist/increment?id=${id}&progress=${progress! + 1}`); }; -- cgit v1.2.3