This commit is contained in:
2020-08-04 15:53:55 +00:00
parent cfece000f3
commit 0e1c43aad1
2 changed files with 9 additions and 9 deletions

View File

@@ -1,7 +1,8 @@
/* xeslint-disable */
let keepChecking = false;
const DEFAULT_POLLING_INTERVAL = 60000;
const DEFAULT_POLLING_INTERVAL = window.$gz.dev ? 20000 : 60000;
//const DEFAULT_POLLING_INTERVAL = 5000;
const MAX_POLLING_INTERVAL = 10 * 60 * 1000; //10 minutes maximum wait time
@@ -11,7 +12,8 @@ export default {
return;
}
keepChecking = true;
let pollingInterval = window.$gz.dev ? 20000 : DEFAULT_POLLING_INTERVAL;
//initial delay so it fetchs "immediately"
let pollingInterval = 3000;
let status = null;
while (keepChecking == true) {
try {
@@ -23,12 +25,16 @@ export default {
} else {
window.$gz.store.commit("setNewNotificationCount", status.data);
//success so go to default in case it was changed by an error
pollingInterval = window.$gz.dev ? 20000 : DEFAULT_POLLING_INTERVAL;
pollingInterval = DEFAULT_POLLING_INTERVAL;
}
} else {
keepChecking = false;
}
} catch (error) {
//fixup if fails on very first iteration with initial short polling interval
if (pollingInterval < DEFAULT_POLLING_INTERVAL) {
pollingInterval = DEFAULT_POLLING_INTERVAL;
}
pollingInterval *= 1.5;
if (pollingInterval > MAX_POLLING_INTERVAL) {
pollingInterval = MAX_POLLING_INTERVAL;