Skip to content

Commit

Permalink
put a timeout on visibilityChange reload library
Browse files Browse the repository at this point in the history
  • Loading branch information
Robonau authored and Robonau committed Dec 10, 2024
1 parent 3d7ef26 commit 5c0c815
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/routes/(app)/(library)/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,20 @@
}
});
let reloadManga = false;
let resetTimeout: NodeJS.Timeout | undefined;
function visibilityChange() {
if (document.hidden) return;
clearTimeout(resetTimeout);
resetTimeout = undefined;
if (document.hidden) {
resetTimeout = setTimeout(() => {
reloadManga = true;
}, 60 * 1000);
return;
}
if (!reloadManga) return;
reloadManga = false;
queryState({
client,
query: getCategory,
Expand Down

0 comments on commit 5c0c815

Please sign in to comment.