Make chapter sort options typing more strict
This commit is contained in:
@@ -80,7 +80,7 @@ export const ChapterOptions: React.FC<IProps> = ({ open, onClose, options, optio
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (key === 'sort') {
|
if (key === 'sort') {
|
||||||
return SORT_OPTIONS.map(([mode, label]) => (
|
return Object.entries(SORT_OPTIONS).map(([mode, label]) => (
|
||||||
<SortRadioInput
|
<SortRadioInput
|
||||||
key={mode}
|
key={mode}
|
||||||
label={t(label)}
|
label={t(label)}
|
||||||
@@ -88,7 +88,7 @@ export const ChapterOptions: React.FC<IProps> = ({ open, onClose, options, optio
|
|||||||
sortDescending={options.reverse}
|
sortDescending={options.reverse}
|
||||||
onClick={() =>
|
onClick={() =>
|
||||||
mode !== options.sortBy
|
mode !== options.sortBy
|
||||||
? optionsDispatch({ type: 'sortBy', sortBy: mode })
|
? optionsDispatch({ type: 'sortBy', sortBy: mode as keyof typeof SORT_OPTIONS })
|
||||||
: optionsDispatch({ type: 'sortReverse' })
|
: optionsDispatch({ type: 'sortReverse' })
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -129,12 +129,12 @@ export const useChapterOptions = (mangaId: number) =>
|
|||||||
defaultChapterOptions,
|
defaultChapterOptions,
|
||||||
);
|
);
|
||||||
|
|
||||||
export const SORT_OPTIONS: [ChapterSortMode, TranslationKey][] = [
|
export const SORT_OPTIONS: Record<ChapterSortMode, TranslationKey> = {
|
||||||
['source', 'global.sort.label.by_source'],
|
source: 'global.sort.label.by_source',
|
||||||
['chapterNumber', 'global.sort.label.by_chapter_number'],
|
chapterNumber: 'global.sort.label.by_chapter_number',
|
||||||
['uploadedAt', 'global.sort.label.by_upload_date'],
|
uploadedAt: 'global.sort.label.by_upload_date',
|
||||||
['fetchedAt', 'global.sort.label.by_fetch_date'],
|
fetchedAt: 'global.sort.label.by_fetch_date',
|
||||||
];
|
};
|
||||||
|
|
||||||
export const isFilterActive = (options: ChapterListOptions) => {
|
export const isFilterActive = (options: ChapterListOptions) => {
|
||||||
const { unread, downloaded, bookmarked } = options;
|
const { unread, downloaded, bookmarked } = options;
|
||||||
|
|||||||
Reference in New Issue
Block a user