changeset 2774:6c1c4f55d99b

sidebar: only update when user is logged in
author Thomas Junk <thomas.junk@intevation.de>
date Fri, 22 Mar 2019 12:45:53 +0100
parents eb1b7479c5e3
children 2feb9f8f6c66
files client/src/components/Sidebar.vue
diffstat 1 files changed, 10 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/client/src/components/Sidebar.vue	Fri Mar 22 11:47:28 2019 +0100
+++ b/client/src/components/Sidebar.vue	Fri Mar 22 12:45:53 2019 +0100
@@ -166,7 +166,7 @@
   },
   computed: {
     ...mapGetters("user", ["isSysAdmin", "isWaterwayAdmin"]),
-    ...mapState("user", ["user", "roles"]),
+    ...mapState("user", ["user", "roles", "isAuthenticated"]),
     ...mapState("application", [
       "showSidebar",
       "showSearchbarLastState",
@@ -200,8 +200,10 @@
         this.contextBoxContent === item &&
         this.routeName == "mainview"
       );
-    },
-    updateIndicators() {
+    }
+  },
+  mounted() {
+    const updateIndicators = () => {
       if (this.isWaterwayAdmin) {
         this.$store;
         HTTP.get("/imports?states=pending&count=true", {
@@ -209,6 +211,9 @@
         })
           .then(response => {
             this.stagingNotifications = response.data;
+            if (this.isAuthenticated) {
+              setTimeout(updateIndicators, 15000);
+            }
           })
           .catch(error => {
             const { status, data } = error.response;
@@ -218,11 +223,8 @@
             });
           });
       }
-    }
-  },
-  mounted() {
-    this.updateIndicators();
-    setInterval(this.updateIndicators, 15000);
+    };
+    setTimeout(updateIndicators, 15000);
   }
 };
 </script>