Fix missing manga action execution failure messages

The manga actions to
- download
- delete downloads
- mark as read
- mark as unread
did not show an error message in case the request to get relevant chapter ids failed.
This commit is contained in:
schroda
2026-05-20 14:52:27 +02:00
parent 4394dbe957
commit 3ae4d8d752

View File

@@ -55,6 +55,8 @@ import type {
UpdateMangaCategoriesPatchInput,
} from '@/lib/graphql/generated/graphql-base.types.ts';
const I18N_PLURAL = 9999;
type DownloadChaptersOptions = {
size?: number;
onlyUnread?: boolean;
@@ -190,6 +192,10 @@ export class Mangas {
{ size, onlyUnread, downloadAhead = false }: DownloadChaptersOptions = {},
disableConfirmation?: boolean,
): Promise<void> {
return Mangas.executeAction(
'download',
I18N_PLURAL,
async () => {
const [chaptersToConsider, unReadDownloadedChapters] = await Promise.all([
Mangas.getChapterIdsWithState(mangaIds, {
isRead: onlyUnread ? false : undefined,
@@ -206,11 +212,17 @@ export class Mangas {
]) satisfies MangaIdToDownloadSize[];
const mangaIdToChaptersToConsider = Object.groupBy(chaptersToConsider, ({ mangaId }) => mangaId);
const mangaIdToUnReadDownloadedChapters = Object.groupBy(unReadDownloadedChapters, ({ mangaId }) => mangaId);
const mangaIdToUnReadDownloadedChapters = Object.groupBy(
unReadDownloadedChapters,
({ mangaId }) => mangaId,
);
const mangaIdToDownloadSize = Object.entries(mangaIdToUnReadDownloadedChapters).map(
([mangaId, downloadedChapters = []]) => {
const downloadAheadSize = Math.max(0, (size ?? downloadedChapters.length) - downloadedChapters.length);
const downloadAheadSize = Math.max(
0,
(size ?? downloadedChapters.length) - downloadedChapters.length,
);
const actualSize = downloadAhead ? downloadAheadSize : size;
return [mangaId, actualSize];
@@ -245,12 +257,31 @@ export class Mangas {
return Promise.resolve();
}
return Chapters.download(Chapters.getIds(chaptersToDownload), disableConfirmation);
try {
await Chapters.download(Chapters.getIds(chaptersToDownload), disableConfirmation);
} catch (e) {
// Ignore - Error gets handled in Chapters
}
},
true,
);
}
static async deleteChapters(mangaIds: number[], disableConfirmation?: boolean): Promise<void> {
return Mangas.executeAction(
'delete',
I18N_PLURAL,
async () => {
const chapters = await Mangas.getChapterIdsWithState(mangaIds, { isDownloaded: true });
return Chapters.delete(Chapters.getIds(chapters), disableConfirmation);
try {
await Chapters.delete(Chapters.getIds(chapters), disableConfirmation);
} catch (e) {
// Ignore - Error gets handled in Chapters
}
},
true,
);
}
static async markAsRead(
@@ -258,18 +289,42 @@ export class Mangas {
wasManuallyMarkedAsRead: boolean = false,
disableConfirmation?: boolean,
): Promise<void> {
return Mangas.executeAction(
'mark_as_read',
I18N_PLURAL,
async () => {
const chapters = await Mangas.getChapterIdsWithState(mangaIds, { isRead: false });
return Chapters.markAsRead(
try {
await Chapters.markAsRead(
chapters,
wasManuallyMarkedAsRead,
mangaIds.length === 1 ? mangaIds[0] : undefined,
disableConfirmation,
);
} catch (e) {
// Ignore - Error gets handled in Chapters
}
},
true,
);
}
static async markAsUnread(mangaIds: number[], disableConfirmation?: boolean): Promise<void> {
return Mangas.executeAction(
'mark_as_unread',
I18N_PLURAL,
async () => {
const chapters = await Mangas.getChapterIdsWithState(mangaIds, { isRead: true });
return Chapters.markAsUnread(Chapters.getIds(chapters), disableConfirmation);
try {
await Chapters.markAsUnread(Chapters.getIds(chapters), disableConfirmation);
} catch (e) {
// Ignore - Error gets handled in Chapters
}
},
true,
);
}
static async removeFromLibrary(mangaIds: number[], disableConfirmation?: boolean): Promise<void> {