From 5c0c815ac7bbd2135b075e4db462d936442c58b4 Mon Sep 17 00:00:00 2001 From: Robonau <30987265+Robonau@users.noreply.github> Date: Tue, 10 Dec 2024 08:04:50 +0000 Subject: [PATCH] put a timeout on visibilityChange reload library --- src/routes/(app)/(library)/+page.svelte | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/routes/(app)/(library)/+page.svelte b/src/routes/(app)/(library)/+page.svelte index a77c200..1a48eb2 100644 --- a/src/routes/(app)/(library)/+page.svelte +++ b/src/routes/(app)/(library)/+page.svelte @@ -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,