Add more chapter list sort options

- by chapter number
- by upload date
This commit is contained in:
schroda
2024-06-30 13:46:09 +02:00
parent bff3c28730
commit d1286c2779
3 changed files with 12 additions and 2 deletions

View File

@@ -420,8 +420,10 @@
}, },
"sort": { "sort": {
"label": { "label": {
"by_chapter_number": "By chapter number",
"by_fetch_date": "By date fetched", "by_fetch_date": "By date fetched",
"by_source": "By source" "by_source": "By source",
"by_upload_date": "By upload date"
} }
}, },
"time": { "time": {

View File

@@ -92,6 +92,12 @@ const sortChapters = (
case 'fetchedAt': case 'fetchedAt':
sortedChapters.sort((a, b) => Number(a.fetchedAt ?? 0) - Number(b.fetchedAt ?? 0)); sortedChapters.sort((a, b) => Number(a.fetchedAt ?? 0) - Number(b.fetchedAt ?? 0));
break; 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: default:
// nothing to do // nothing to do
} }
@@ -125,6 +131,8 @@ export const useChapterOptions = (mangaId: number) =>
export const SORT_OPTIONS: [ChapterSortMode, TranslationKey][] = [ export const SORT_OPTIONS: [ChapterSortMode, TranslationKey][] = [
['source', 'global.sort.label.by_source'], ['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'], ['fetchedAt', 'global.sort.label.by_fetch_date'],
]; ];

View File

@@ -377,7 +377,7 @@ export type PaginatedMangaList = {
export type NullAndUndefined<T> = T | null | undefined; export type NullAndUndefined<T> = T | null | undefined;
export type ChapterSortMode = 'fetchedAt' | 'source'; export type ChapterSortMode = 'fetchedAt' | 'source' | 'chapterNumber' | 'uploadedAt';
export interface ChapterListOptions { export interface ChapterListOptions {
active: boolean; active: boolean;