Cleanup chapter download option menu

This commit is contained in:
schroda
2025-07-05 15:51:07 +02:00
parent 8631da1ce4
commit 99e5eb2dac
2 changed files with 29 additions and 33 deletions

View File

@@ -81,10 +81,8 @@
"confirmation_other": "You are about to download {{count}} chapters.\nSuwayomi is not a mass downloader and too many downloads can get you banned from sources and/or cause performance issues.", "confirmation_other": "You are about to download {{count}} chapters.\nSuwayomi is not a mass downloader and too many downloads can get you banned from sources and/or cause performance issues.",
"error_one": "Could not add the download", "error_one": "Could not add the download",
"error_other": "Could not add downloads", "error_other": "Could not add downloads",
"next": "$t(reader.button.next_chapter)", "next_one": "Next chapter",
"next_five": "Next 5 chapters", "next_other" : "Next {{count}} chapters",
"next_ten": "Next 10 chapters",
"next_twentyfive": "Next 25 chapters",
"success_one": "Download added", "success_one": "Download added",
"success_other": "{{count}} downloads added", "success_other": "{{count}} downloads added",
"unread": "$t(global.filter.label.unread)" "unread": "$t(global.filter.label.unread)"

View File

@@ -12,14 +12,25 @@ import { useMetadataServerSettings } from '@/modules/settings/services/ServerSet
import { Mangas } from '@/modules/manga/services/Mangas.ts'; import { Mangas } from '@/modules/manga/services/Mangas.ts';
import { defaultPromiseErrorHandler } from '@/lib/DefaultPromiseErrorHandler.ts'; import { defaultPromiseErrorHandler } from '@/lib/DefaultPromiseErrorHandler.ts';
import { MangaType } from '@/lib/graphql/generated/graphql.ts'; import { MangaType } from '@/lib/graphql/generated/graphql.ts';
import { TranslationKey } from '@/Base.types.ts';
const DownloadRange = { const DOWNLOAD_OPTIONS: {
NEXT_1: 1, title: TranslationKey;
NEXT_5: 5, getCount: (downloadAheadLimit: number) => number | undefined;
NEXT_10: 10, onlyUnread?: boolean;
NEXT_25: 25, }[] = [
ALL: undefined, { title: 'chapter.action.download.add.label.next', getCount: () => 1 },
}; { title: 'chapter.action.download.add.label.next', getCount: () => 5 },
{ title: 'chapter.action.download.add.label.next', getCount: () => 10 },
{ title: 'chapter.action.download.add.label.next', getCount: () => 25 },
{
title: 'chapter.action.download.add.label.ahead',
getCount: (downloadAheadLimit) => downloadAheadLimit,
onlyUnread: true,
},
{ title: 'chapter.action.download.add.label.unread', getCount: () => undefined, onlyUnread: true },
{ title: 'chapter.action.download.add.label.all', getCount: () => undefined, onlyUnread: false },
];
export const ChaptersDownloadActionMenuItems = ({ export const ChaptersDownloadActionMenuItems = ({
mangaIds, mangaIds,
@@ -39,33 +50,20 @@ export const ChaptersDownloadActionMenuItems = ({
downloadAhead, downloadAhead,
onlyUnread, onlyUnread,
size, size,
}).catch(defaultPromiseErrorHandler('ChapterDownloadButton::handleSelect')); }).catch(defaultPromiseErrorHandler('ChaptersDownloadActionMenuItems::handleSelect'));
closeMenu?.(); closeMenu?.();
}; };
return ( return (
<> <>
<MenuItem onClick={() => handleSelect(DownloadRange.NEXT_1)}> {DOWNLOAD_OPTIONS.map(({ title, getCount, onlyUnread }) => (
{t('chapter.action.download.add.label.next')} <MenuItem
</MenuItem> key={t(title, { count: getCount(downloadAheadLimit) })}
<MenuItem onClick={() => handleSelect(DownloadRange.NEXT_5)}> onClick={() => handleSelect(getCount(downloadAheadLimit), onlyUnread)}
{t('chapter.action.download.add.label.next_five')} >
</MenuItem> {t(title, { count: getCount(downloadAheadLimit) })}
<MenuItem onClick={() => handleSelect(DownloadRange.NEXT_10)}> </MenuItem>
{t('chapter.action.download.add.label.next_ten')} ))}
</MenuItem>
<MenuItem onClick={() => handleSelect(DownloadRange.NEXT_25)}>
{t('chapter.action.download.add.label.next_twentyfive')}
</MenuItem>
<MenuItem onClick={() => handleSelect(downloadAheadLimit, undefined, true)}>
{t('chapter.action.download.add.label.ahead', { count: downloadAheadLimit })}
</MenuItem>
<MenuItem onClick={() => handleSelect(DownloadRange.ALL, true)}>
{t('chapter.action.download.add.label.unread')}
</MenuItem>
<MenuItem onClick={() => handleSelect(DownloadRange.ALL, false)}>
{t('chapter.action.download.add.label.all')}
</MenuItem>
</> </>
); );
}; };