Use gql for "updating chapters"

This commit is contained in:
schroda
2023-09-01 20:36:40 +02:00
parent c75e184c57
commit f0d55c01c8
7 changed files with 99 additions and 44 deletions

View File

@@ -74,7 +74,7 @@ const DownloadQueue: React.FC = () => {
requestManager.removeChapterFromDownloadQueue(chapter.mangaId, chapter.index).response,
// delete partial download, should be handle server side?
// bug: The folder and the last image downloaded are not deleted
requestManager.deleteDownloadedChapter(chapter.mangaId, chapter.index).response,
requestManager.deleteDownloadedChapter(chapter.id).response,
]);
} catch (error) {
makeToast(t('download.queue.error.label.failed_to_remove'), 'error');

View File

@@ -85,7 +85,7 @@ const initialChapter = {
chapterCount: 0,
lastPageRead: 0,
name: 'Loading...',
};
} as IChapter;
export default function Reader() {
const { t } = useTranslation();
@@ -207,19 +207,19 @@ export default function Reader() {
// do not mutate the chapter, this will cause the page to jump around due to always scrolling to the last read page
if (curPage !== -1) {
requestManager.updateChapter(manga.id, chapter.index, { lastPageRead: curPage });
requestManager.updateChapter(chapter.id, { lastPageRead: curPage });
}
if (curPage === chapter.pageCount - 1) {
requestManager.updateChapter(manga.id, chapter.index, { read: true });
requestManager.updateChapter(chapter.id, { isRead: true });
}
}, [curPage]);
const nextChapter = useCallback(() => {
if (chapter.index < chapter.chapterCount) {
requestManager.updateChapter(manga.id, chapter.index, {
requestManager.updateChapter(chapter.id, {
lastPageRead: chapter.pageCount - 1,
read: true,
isRead: true,
});
openNextChapter(ChapterOffset.NEXT, (nextChapterIndex) =>