Feature/gql improve queries mutations subscriptions (#470)

* [Codegen] Request less fields for category mutations

* [Codegen] Request less fields for chapter mutations

* [Codegen] Request less fields for downloader mutations

* [Codegen] Request less fields for extension mutations

* [Codegen] Request less fields for manga mutations

* [Codegen] Request less fields for source mutations

* [Codegen] Request less fields for updater subscription

* [Codegen] Request less fields for downloader subscription

* [Codegen] Combine chapter update mutations
This commit is contained in:
schroda
2023-11-24 03:17:49 +01:00
committed by GitHub
parent 3b147b1b46
commit 7adc28a35c
12 changed files with 443 additions and 198 deletions

View File

@@ -70,19 +70,16 @@ export const ChapterCard: React.FC<IProps> = (props: IProps) => {
const sendChange = <Key extends keyof UpdatePatchInput>(key: Key, value: UpdatePatchInput[Key]) => {
handleClose();
const shouldDeleteChapter = ({ isBookmarked, isDownloaded }: TChapter) =>
isDownloaded && (!isBookmarked || metadataServerSettings.deleteChaptersWithBookmark);
const isMarkAsRead = (key === 'isRead' && value) || key === 'markPrevRead';
const shouldAutoDeleteChapters = isMarkAsRead && metadataServerSettings.deleteChaptersManuallyMarkedRead;
if (shouldAutoDeleteChapters) {
const shouldDeleteChapter = ({ isBookmarked, isDownloaded }: TChapter) =>
isDownloaded && (!isBookmarked || metadataServerSettings.deleteChaptersWithBookmark);
const chaptersToDelete = key === 'isRead' ? [chapter] : allChapters;
const chapterIdsToDelete = chaptersToDelete
.filter(shouldDeleteChapter)
.map(({ id: chapterId }) => chapterId);
requestManager.deleteDownloadedChapters(chapterIdsToDelete).response.catch(() => {});
}
const chaptersToDelete = key === 'isRead' ? [chapter] : allChapters;
const chapterIdsToDelete = shouldAutoDeleteChapters
? chaptersToDelete.filter(shouldDeleteChapter).map(({ id: chapterId }) => chapterId)
: [];
if (key === 'markPrevRead') {
const index = allChapters.findIndex(({ id: chapterId }) => chapterId === chapter.id);
@@ -91,7 +88,7 @@ export const ChapterCard: React.FC<IProps> = (props: IProps) => {
.slice(index)
.filter(({ isRead }) => !isRead)
.map(({ id: chapterId }) => chapterId),
{ isRead: true },
{ isRead: true, chapterIdsToDelete },
);
return;
}
@@ -99,6 +96,7 @@ export const ChapterCard: React.FC<IProps> = (props: IProps) => {
requestManager.updateChapter(chapter.id, {
[key]: value,
lastPageRead: key === 'isRead' ? 0 : undefined,
deleteChapter: !!chapterIdsToDelete.length,
});
};