From 60985ce13d06161a54a0c3d8859164177c5c5864 Mon Sep 17 00:00:00 2001 From: Fuwn Date: Wed, 30 Aug 2023 16:31:01 -0700 Subject: fix(mangadex): optimise and fix chapter language --- src/lib/mangadex.ts | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) (limited to 'src/lib/mangadex.ts') diff --git a/src/lib/mangadex.ts b/src/lib/mangadex.ts index 9ab65d75..f6b6b407 100644 --- a/src/lib/mangadex.ts +++ b/src/lib/mangadex.ts @@ -36,17 +36,7 @@ export const chapterCount = async (manga: Media): Promise => { return null; } - let lastChapterIndex = 0; - - for (let i = 0; i < lastChapterData['data'].length; i++) { - if (lastChapterData['data'][i]['attributes']['volume'] !== null) { - lastChapterIndex = i; - - break; - } - } - - let lastChapter = lastChapterData['data'][lastChapterIndex]['attributes']['chapter']; + let lastChapter = lastChapterData['data'][0]['attributes']['chapter']; if (lastChapter == 0) { lastChapter = null; @@ -54,8 +44,8 @@ export const chapterCount = async (manga: Media): Promise => { await chapterDatabase.chapters.put({ id: manga.id, - chapters: lastChapter + chapters: Number(lastChapter) }); - return lastChapter; + return Number(lastChapter); }; -- cgit v1.2.3