File tree Expand file tree Collapse file tree 1 file changed +10
-9
lines changed
frontend/src/components/shared Expand file tree Collapse file tree 1 file changed +10
-9
lines changed Original file line number Diff line number Diff line change @@ -71,6 +71,7 @@ export default {
7171 // ],
7272 notifications: [],
7373 showNotifications: false ,
74+ fetchNotificationsIntervalId: null ,
7475 }),
7576 methods: {
7677 getRouterLink (link ) {
@@ -136,22 +137,22 @@ export default {
136137 this .notify = notifications .length ;
137138 },
138139 async fetchNewNotifications () {
139- const notificationsRequest = await this .$http .get (' /notifications/unread' );
140- const { notifications } = notificationsRequest .data ;
141- const count = notifications .length ;
142- if (! count) {
140+ const newNotificationsRequest = await this .$http .get (' /notifications/unread' );
141+ const newNotifications = newNotificationsRequest .data .notifications ;
142+ if (! newNotifications .length ) {
143143 return ;
144144 }
145- for (let i = 0 ; i < count; i += 1 ) {
146- this .notifications .unshift (notifications[i]);
147- }
145+ await this .fetchNotifications ();
148146 this .notify = true ;
149147 },
150148 },
151149 async beforeMount () {
152150 await this .fetchNotifications ();
153- // await this.newNotificationCheck();
154- await this .fetchNewNotifications ();
151+ await this .newNotificationCheck ();
152+ this .fetchNotificationsIntervalId = setInterval (this .fetchNewNotifications , 5000 );
153+ },
154+ beforeDestroy () {
155+ window .clearInterval (this .fetchNotificationsIntervalId );
155156 },
156157};
157158 </script >
You can’t perform that action at this time.
0 commit comments