From 11b2160b6a500fdc1a00cdbb77bc52715ee4b9e8 Mon Sep 17 00:00:00 2001 From: Tony Air Date: Fri, 11 Sep 2020 03:11:51 +0700 Subject: [PATCH] IMPR: AJAX online/offline handling --- src/js/_main.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/js/_main.js b/src/js/_main.js index a09124f..d66ffce 100755 --- a/src/js/_main.js +++ b/src/js/_main.js @@ -121,7 +121,13 @@ const MainUI = (($) => { }; // update online/offline state + let statusLock = false; const updateOnlineStatus = () => { + if (statusLock) { + return; + } + statusLock = true; + if (typeof navigator.onLine === 'undefined') { return false; } @@ -138,6 +144,7 @@ const MainUI = (($) => { $Body.trigger(Events.OFFLINE); $W.trigger(Events.OFFLINE); + statusLock = false; return true; } @@ -158,6 +165,7 @@ const MainUI = (($) => { $Body.trigger(Events.ONLINE); $W.trigger(Events.ONLINE); + statusLock = false; return true; };