From d1286c2779af3a9ec8542500c70008f710e71daf Mon Sep 17 00:00:00 2001 From: schroda <50052685+schroda@users.noreply.github.com> Date: Sun, 30 Jun 2024 13:46:09 +0200 Subject: [PATCH] Add more chapter list sort options - by chapter number - by upload date --- public/locales/en.json | 4 +++- src/components/chapter/util.tsx | 8 ++++++++ src/typings.ts | 2 +- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/public/locales/en.json b/public/locales/en.json index 437e1db7..31829887 100644 --- a/public/locales/en.json +++ b/public/locales/en.json @@ -420,8 +420,10 @@ }, "sort": { "label": { + "by_chapter_number": "By chapter number", "by_fetch_date": "By date fetched", - "by_source": "By source" + "by_source": "By source", + "by_upload_date": "By upload date" } }, "time": { diff --git a/src/components/chapter/util.tsx b/src/components/chapter/util.tsx index 01b52b11..01fd4477 100644 --- a/src/components/chapter/util.tsx +++ b/src/components/chapter/util.tsx @@ -92,6 +92,12 @@ const sortChapters = ( case 'fetchedAt': sortedChapters.sort((a, b) => Number(a.fetchedAt ?? 0) - Number(b.fetchedAt ?? 0)); break; + case 'chapterNumber': + sortedChapters.sort((a, b) => a.chapterNumber - b.chapterNumber); + break; + case 'uploadedAt': + sortedChapters.sort((a, b) => Number(a.uploadDate ?? 0) - Number(b.uploadDate ?? 0)); + break; default: // nothing to do } @@ -125,6 +131,8 @@ export const useChapterOptions = (mangaId: number) => export const SORT_OPTIONS: [ChapterSortMode, TranslationKey][] = [ ['source', 'global.sort.label.by_source'], + ['chapterNumber', 'global.sort.label.by_chapter_number'], + ['uploadedAt', 'global.sort.label.by_upload_date'], ['fetchedAt', 'global.sort.label.by_fetch_date'], ]; diff --git a/src/typings.ts b/src/typings.ts index 9c3af077..40d24741 100644 --- a/src/typings.ts +++ b/src/typings.ts @@ -377,7 +377,7 @@ export type PaginatedMangaList = { export type NullAndUndefined = T | null | undefined; -export type ChapterSortMode = 'fetchedAt' | 'source'; +export type ChapterSortMode = 'fetchedAt' | 'source' | 'chapterNumber' | 'uploadedAt'; export interface ChapterListOptions { active: boolean;