Added sort by last read (#254)

This commit is contained in:
akabhirav
2023-03-05 12:26:50 +05:30
committed by GitHub
parent e32078917d
commit 91e7bd2b27
5 changed files with 10 additions and 1 deletions

View File

@@ -70,6 +70,8 @@ const sortByTitle = (a: IMangaCard, b: IMangaCard): number => a.title.localeComp
const sortByDateAdded = (a: IMangaCard, b: IMangaCard): number => a.inLibraryAt - b.inLibraryAt;
const sortByLastRead = (a: IMangaCard, b: IMangaCard): number => b.lastReadAt - a.lastReadAt;
const sortManga = (
manga: IMangaCard[],
sort: NullAndUndefined<LibrarySortMode>,
@@ -87,6 +89,9 @@ const sortManga = (
case 'sortToRead':
result.sort(sortByUnread);
break;
case 'sortLastRead':
result.sort(sortByLastRead);
break;
default:
break;
}

View File

@@ -25,6 +25,7 @@ const SORT_OPTIONS: [LibrarySortMode, string][] = [
['sortToRead', 'By Unread chapters'],
['sortAlph', 'Alphabetically'],
['sortDateAdded', 'Date Added'],
['sortLastRead', 'Last Read'],
];
interface IProps {