diff --git a/ayanova/src/App.vue b/ayanova/src/App.vue
index f23e7507..f47aa843 100644
--- a/ayanova/src/App.vue
+++ b/ayanova/src/App.vue
@@ -151,9 +151,9 @@
-
+
- 4
+ {{ newNotificationCount() }}
fa-bell
@@ -376,6 +376,9 @@ export default {
},
clickMenuItem(item) {
window.$gz.eventBus.$emit("menu-click", item);
+ },
+ newNotificationCount() {
+ return this.$store.state.newNotificationCount;
}
}
};
diff --git a/ayanova/src/api/notifypoll.js b/ayanova/src/api/notifypoll.js
index 7616d508..db544188 100644
--- a/ayanova/src/api/notifypoll.js
+++ b/ayanova/src/api/notifypoll.js
@@ -1,23 +1,29 @@
/* xeslint-disable */
let keepPolling = false;
+const DEFAULT_POLLING_INTERVAL = 10000;
+const MAX_POLLING_INTERVAL = 15 * 60 * 1000; //15 minutes maximum wait time
export default {
async startPolling() {
- console.log("notifypoll::starting polling");
keepPolling = true;
+ let pollingInterval = DEFAULT_POLLING_INTERVAL;
try {
while (keepPolling == true) {
let status = await window.$gz.api.get("notify/new-count");
if (status.error) {
throw status.error;
}
- console.log("notifypoll::new count ", status);
- // window.$gz.store.commit("setNotifyNewCount", status.data);
- await window.$gz.util.sleepAsync(10000);
+ window.$gz.store.commit("setNewNotificationCount", status.data);
+ //success so go to default in case it was changed by an error
+ pollingInterval = DEFAULT_POLLING_INTERVAL;
+ await window.$gz.util.sleepAsync(pollingInterval);
}
} catch (error) {
- keepPolling = false;
+ pollingInterval *= 1.5;
+ if (pollingInterval > MAX_POLLING_INTERVAL) {
+ pollingInterval = MAX_POLLING_INTERVAL;
+ }
window.$gz.errorHandler.handleGeneralError(
"Error checking for notifications",
"notifypoll",
@@ -33,6 +39,5 @@ export default {
},
stopPolling() {
keepPolling = false;
- console.log("notifypoll::stopping polling");
}
};
diff --git a/ayanova/src/store.js b/ayanova/src/store.js
index 3d1ec878..fcc5d2bd 100644
--- a/ayanova/src/store.js
+++ b/ayanova/src/store.js
@@ -45,7 +45,8 @@ export default new Vuex.Store({
formSettings: {}, //this is the settings on forms that survive a refresh like grid number of items to show etc
formCustomTemplate: {}, //this is the custom fields settings for forms,
darkMode: false,
- knownPassword: false
+ knownPassword: false,
+ newNotificationCount: 0
},
mutations: {
setLastClientVersion(state, data) {
@@ -82,6 +83,7 @@ export default new Vuex.Store({
state.locale.hour12 = true;
state.globalSettings = {};
state.knownPassword = false;
+ state.newNotificationCount = 0;
},
addNavItem(state, data) {
state.navItems.push(data);
@@ -149,6 +151,9 @@ export default new Vuex.Store({
},
setKnownPassword(state, data) {
state.knownPassword = data;
+ },
+ setNewNotificationCount(state, data) {
+ state.newNotificationCount = data;
}
},
actions: {}