Skip to content

Commit

Permalink
Merge pull request #251 from Suwayomi/main
Browse files Browse the repository at this point in the history
on visibilitychange reload library
  • Loading branch information
Robonau authored Dec 10, 2024
2 parents b7a2113 + 3d7ef26 commit d6ecf5e
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions src/routes/(app)/(library)/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -230,18 +230,21 @@
}
});
onMount(() => {
const removeOnVisibilityChange = (document.onvisibilitychange = () => {
if (document.visibilityState === 'visible') {
queryState({
client,
query: getCategory,
variables: { id: $tab ?? 0 },
requestPolicy: 'network-only'
});
}
function visibilityChange() {
if (document.hidden) return;
queryState({
client,
query: getCategory,
variables: { id: $tab ?? 0 },
requestPolicy: 'network-only'
});
return removeOnVisibilityChange;
}
onMount(() => {
document.addEventListener('visibilitychange', visibilityChange);
return () => {
document.removeEventListener('visibilitychange', visibilityChange);
};
});
let mangas = $derived(
Expand Down

0 comments on commit d6ecf5e

Please sign in to comment.