Skip to content

Commit

Permalink
Merge pull request #91 from Suwayomi/main
Browse files Browse the repository at this point in the history
fix updateChapter looping
  • Loading branch information
Robonau authored Nov 17, 2023
2 parents 1c00999 + 373b591 commit b506cc1
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@
});
}
let lastupdate = 0;
let updatedChaps: string[] = [];
function PageIntersect(
e: CustomEvent<boolean>,
Expand All @@ -319,15 +319,19 @@
pageIndex
}
];
if (lastupdate !== pageIndex) {
if (!updatedChaps.includes(selector)) {
console.log(e.detail, selector);
updateChapter({
variables: {
id,
lastPageRead: pageIndex,
isRead: pageIndex >= maxPages * 0.8 ? true : null
}
});
lastupdate = pageIndex;
updatedChaps.push(selector);
setTimeout(() => {
updatedChaps = updatedChaps.filter((e) => e !== selector);
}, 5000);
}
} else {
visiblePages = visiblePages.filter((e) => e.selector !== selector);
Expand Down

0 comments on commit b506cc1

Please sign in to comment.