Replace Sort by ID with Date Added (#253)
This commit is contained in:
@@ -68,7 +68,7 @@ const sortByUnread = (a: IMangaCard, b: IMangaCard): number =>
|
|||||||
|
|
||||||
const sortByTitle = (a: IMangaCard, b: IMangaCard): number => a.title.localeCompare(b.title);
|
const sortByTitle = (a: IMangaCard, b: IMangaCard): number => a.title.localeCompare(b.title);
|
||||||
|
|
||||||
const sortById = (a: IMangaCard, b: IMangaCard): number => a.id - b.id;
|
const sortByDateAdded = (a: IMangaCard, b: IMangaCard): number => a.inLibraryAt - b.inLibraryAt;
|
||||||
|
|
||||||
const sortManga = (
|
const sortManga = (
|
||||||
manga: IMangaCard[],
|
manga: IMangaCard[],
|
||||||
@@ -81,8 +81,8 @@ const sortManga = (
|
|||||||
case 'sortAlph':
|
case 'sortAlph':
|
||||||
result.sort(sortByTitle);
|
result.sort(sortByTitle);
|
||||||
break;
|
break;
|
||||||
case 'sortID':
|
case 'sortDateAdded':
|
||||||
result.sort(sortById);
|
result.sort(sortByDateAdded);
|
||||||
break;
|
break;
|
||||||
case 'sortToRead':
|
case 'sortToRead':
|
||||||
result.sort(sortByUnread);
|
result.sort(sortByUnread);
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ const TITLES = {
|
|||||||
const SORT_OPTIONS: [LibrarySortMode, string][] = [
|
const SORT_OPTIONS: [LibrarySortMode, string][] = [
|
||||||
['sortToRead', 'By Unread chapters'],
|
['sortToRead', 'By Unread chapters'],
|
||||||
['sortAlph', 'Alphabetically'],
|
['sortAlph', 'Alphabetically'],
|
||||||
['sortID', 'By ID'],
|
['sortDateAdded', 'Date Added'],
|
||||||
];
|
];
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
|
|||||||
@@ -72,6 +72,7 @@ export default function Reader() {
|
|||||||
title: '',
|
title: '',
|
||||||
thumbnailUrl: '',
|
thumbnailUrl: '',
|
||||||
genre: [],
|
genre: [],
|
||||||
|
inLibraryAt: 0,
|
||||||
});
|
});
|
||||||
const [chapter, setChapter] = useState<IChapter | IPartialChapter>(initialChapter());
|
const [chapter, setChapter] = useState<IChapter | IPartialChapter>(initialChapter());
|
||||||
const [curPage, setCurPage] = useState<number>(0);
|
const [curPage, setCurPage] = useState<number>(0);
|
||||||
|
|||||||
@@ -204,6 +204,7 @@ export default function SourceMangas(props: { popular: boolean }) {
|
|||||||
id: it.id,
|
id: it.id,
|
||||||
inLibrary: it.inLibrary,
|
inLibrary: it.inLibrary,
|
||||||
genre: it.genre,
|
genre: it.genre,
|
||||||
|
inLibraryAt: it.inLibraryAt,
|
||||||
})),
|
})),
|
||||||
]);
|
]);
|
||||||
setHasNextPage(data.hasNextPage);
|
setHasNextPage(data.hasNextPage);
|
||||||
|
|||||||
@@ -98,6 +98,7 @@ export interface IMangaCard {
|
|||||||
downloadCount?: number;
|
downloadCount?: number;
|
||||||
inLibrary?: boolean;
|
inLibrary?: boolean;
|
||||||
meta?: IMetadata;
|
meta?: IMetadata;
|
||||||
|
inLibraryAt: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IManga {
|
export interface IManga {
|
||||||
@@ -126,6 +127,14 @@ export interface IManga {
|
|||||||
|
|
||||||
age: number;
|
age: number;
|
||||||
chaptersAge: number;
|
chaptersAge: number;
|
||||||
|
chaptersLastFetchedAt: number;
|
||||||
|
inLibraryAt: number;
|
||||||
|
initialized: boolean;
|
||||||
|
lastChapterRead: NullAndUndefined<IChapter>;
|
||||||
|
lastFetchedAt: number;
|
||||||
|
lastReadAt: number;
|
||||||
|
thumbnailUrlLastFetched: number;
|
||||||
|
updateStrategy: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IChapter {
|
export interface IChapter {
|
||||||
@@ -322,7 +331,7 @@ export type ChapterOptionsReducerAction =
|
|||||||
| { type: 'sortReverse' }
|
| { type: 'sortReverse' }
|
||||||
| { type: 'showChapterNumber' };
|
| { type: 'showChapterNumber' };
|
||||||
|
|
||||||
export type LibrarySortMode = 'sortToRead' | 'sortAlph' | 'sortID';
|
export type LibrarySortMode = 'sortToRead' | 'sortAlph' | 'sortDateAdded';
|
||||||
|
|
||||||
enum GridLayout {
|
enum GridLayout {
|
||||||
Compact = 0,
|
Compact = 0,
|
||||||
|
|||||||
@@ -24,4 +24,4 @@
|
|||||||
"include": [
|
"include": [
|
||||||
"src"
|
"src"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user