Skip to content

Commit

Permalink
Do not use stale chapter data for the reader (#358)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
schroda authored Jun 8, 2023
1 parent 67e554e commit 7f83bb9
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/screens/Reader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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 });
}
Expand Down

0 comments on commit 7f83bb9

Please sign in to comment.