IMPR: AJAX online/offline handling

This commit is contained in:
Tony Air 2020-09-11 03:11:51 +07:00
parent 26a1274b43
commit 11b2160b6a
1 changed files with 8 additions and 0 deletions

View File

@ -121,7 +121,13 @@ const MainUI = (($) => {
}; };
// update online/offline state // update online/offline state
let statusLock = false;
const updateOnlineStatus = () => { const updateOnlineStatus = () => {
if (statusLock) {
return;
}
statusLock = true;
if (typeof navigator.onLine === 'undefined') { if (typeof navigator.onLine === 'undefined') {
return false; return false;
} }
@ -138,6 +144,7 @@ const MainUI = (($) => {
$Body.trigger(Events.OFFLINE); $Body.trigger(Events.OFFLINE);
$W.trigger(Events.OFFLINE); $W.trigger(Events.OFFLINE);
statusLock = false;
return true; return true;
} }
@ -158,6 +165,7 @@ const MainUI = (($) => {
$Body.trigger(Events.ONLINE); $Body.trigger(Events.ONLINE);
$W.trigger(Events.ONLINE); $W.trigger(Events.ONLINE);
statusLock = false;
return true; return true;
}; };