From 78090b700bd51545e014d668cf318208700229b1 Mon Sep 17 00:00:00 2001 From: Abdullah Atta Date: Tue, 20 Aug 2024 15:38:22 +0500 Subject: [PATCH] web: remove debouncer for page visibility and connection changes --- apps/web/src/utils/page-visibility.ts | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/apps/web/src/utils/page-visibility.ts b/apps/web/src/utils/page-visibility.ts index 818c1c360..828871fd9 100644 --- a/apps/web/src/utils/page-visibility.ts +++ b/apps/web/src/utils/page-visibility.ts @@ -17,8 +17,6 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -import { debounce } from "@notesnook/common"; - export const PAGE_VISIBILITY_CHANGE = { ignore: false }; function visibilityChange() { return "msHidden" in document @@ -39,8 +37,8 @@ function isDocumentHidden() { export function onNetworkStatusChanged( handler: (status: "online" | "offline") => void ) { - const onlineListener = debounce((_) => handler("online"), 1000); - const offlineListener = debounce((_) => handler("online"), 1000); + const onlineListener = () => handler("online"); + const offlineListener = () => handler("online"); window.addEventListener("online", onlineListener); window.addEventListener("offline", offlineListener); @@ -56,25 +54,25 @@ export function onPageVisibilityChanged( isDocumentHidden: boolean ) => void ) { - const onVisibilityChanged = debounce((_) => { + const onVisibilityChanged = () => { if (isEventIgnored()) return; handler("visibilitychange", isDocumentHidden()); - }, 1000); + }; - const onFocus = debounce((_) => { + const onFocus = () => { if (isEventIgnored()) return; if (!window.document.hasFocus()) return; handler("focus", false); - }, 1000); + }; - const onBlur = debounce((_) => { + const onBlur = () => { if (isEventIgnored()) return; if (window.document.hasFocus()) return; handler("blur", true); - }, 1000); + }; document.addEventListener(visibilityChange(), onVisibilityChanged); window.addEventListener("focus", onFocus);