Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replaces Sort by ID with Date Added #253

Merged
merged 1 commit into from
Mar 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v16.19.1
6 changes: 3 additions & 3 deletions src/components/library/LibraryMangaGrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ const sortByUnread = (a: IMangaCard, b: IMangaCard): number =>

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 = (
manga: IMangaCard[],
Expand All @@ -80,8 +80,8 @@ const sortManga = (
case 'sortAlph':
result.sort(sortByTitle);
break;
case 'sortID':
result.sort(sortById);
case 'sortDateAdded':
result.sort(sortByDateAdded);
break;
case 'sortToRead':
result.sort(sortByUnread);
Expand Down
2 changes: 1 addition & 1 deletion src/components/library/LibraryOptionsPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const TITLES = {
const SORT_OPTIONS: [LibrarySortMode, string][] = [
['sortToRead', 'By Unread chapters'],
['sortAlph', 'Alphabetically'],
['sortID', 'By ID'],
['sortDateAdded', 'Date Added'],
];

interface IProps {
Expand Down
1 change: 1 addition & 0 deletions src/screens/Reader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ export default function Reader() {
title: '',
thumbnailUrl: '',
genre: [],
inLibraryAt: 0,
});
const [chapter, setChapter] = useState<IChapter | IPartialChapter>(initialChapter());
const [curPage, setCurPage] = useState<number>(0);
Expand Down
1 change: 1 addition & 0 deletions src/screens/SourceMangas.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ export default function SourceMangas(props: { popular: boolean }) {
id: it.id,
inLibrary: it.inLibrary,
genre: it.genre,
inLibraryAt: it.inLibraryAt,
})),
]);
setHasNextPage(data.hasNextPage);
Expand Down
11 changes: 10 additions & 1 deletion src/typings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ export interface IMangaCard {
downloadCount?: number;
inLibrary?: boolean;
meta?: IMetadata;
inLibraryAt: number;
}

export interface IManga {
Expand Down Expand Up @@ -124,6 +125,14 @@ export interface IManga {

age: number;
chaptersAge: number;
chaptersLastFetchedAt: number;
inLibraryAt: number;
initialized: boolean;
lastChapterRead: NullAndUndefined<IChapter>;
lastFetchedAt: number;
lastReadAt: number;
thumbnailUrlLastFetched: number;
updateStrategy: string;
}

export interface IChapter {
Expand Down Expand Up @@ -316,7 +325,7 @@ export type ChapterOptionsReducerAction =
| { type: 'sortReverse' }
| { type: 'showChapterNumber' };

export type LibrarySortMode = 'sortToRead' | 'sortAlph' | 'sortID';
export type LibrarySortMode = 'sortToRead' | 'sortAlph' | 'sortDateAdded';

enum GridLayout {
Compact = 0,
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@
"include": [
"src"
]
}
}