From dddde7a7872e8422f15e5c27167d1ba4c0f62674 Mon Sep 17 00:00:00 2001 From: Fuwn Date: Thu, 14 Sep 2023 14:36:33 -0700 Subject: fix(mangadex): better estimates --- src/lib/mangadex.ts | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) (limited to 'src/lib/mangadex.ts') diff --git a/src/lib/mangadex.ts b/src/lib/mangadex.ts index b17a2ffa..5c73aced 100644 --- a/src/lib/mangadex.ts +++ b/src/lib/mangadex.ts @@ -20,21 +20,12 @@ export const chapterCount = async ( const tryRecentMediaActivities = async () => { const anilistData = await recentMediaActivities(identity, manga); - if (anilistData !== null) { - await chapterDatabase.chapters.put({ - id: manga.id, - chapters: anilistData - }); - - return anilistData; - } - await chapterDatabase.chapters.put({ id: manga.id, - chapters: -1 + chapters: anilistData ? anilistData : -1 }); - return null; + return anilistData; }; const mangadexData = await ( @@ -57,7 +48,7 @@ export const chapterCount = async ( let lastChapter = lastChapterData['data'][0]['attributes']['chapter']; - if ((manga.mediaListEntry || { progress: 0 }).progress >= lastChapter) { + if ((manga.mediaListEntry || { progress: 0 }).progress > lastChapter) { const anilistData = await recentMediaActivities(identity, manga); if (anilistData !== null && anilistData > lastChapter) { @@ -66,7 +57,7 @@ export const chapterCount = async ( } if (lastChapter == 0) { - lastChapter = null; + lastChapter = -1; } await chapterDatabase.chapters.put({ -- cgit v1.2.3