Do not use stale chapter data for the reader (#358)

This caused the chapter to be loaded with stale data (the old lastPageRead state) and then jumping to the actual lastPageRead after the latest data was received.

It's not possible to mutate the chapter when updating lastPageRead since this causes the reader to always jump back to the just set lastPageRead when scrolling
This commit is contained in:
schroda
2023-06-08 13:46:55 +02:00
committed by GitHub
parent 67e554ede6
commit 7f83bb9a0a

View File

@@ -107,6 +107,7 @@ export default function Reader() {
const { data: chapter = initialChapter, isLoading: isChapterLoading } = requestManager.useGetChapter(
mangaId,
chapterIndex,
{ disableCache: true },
);
const [wasLastPageReadSet, setWasLastPageReadSet] = useState(false);
const [curPage, setCurPage] = useState<number>(0);
@@ -204,6 +205,7 @@ export default function Reader() {
return;
}
// 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 });
}