2626 'word-break': true,
2727 'border-b': true,
2828 'font-bold': !notification.is_seen,}"
29- v-for =" notification in notifications" :key =" notification.id " >
29+ v-for =" ( notification, index) in notifications" :key =" index " >
3030 <router-link
3131 v-bind:to =" notification.link_to"
3232 class =" py-4 flex items-center word-break cursor-pointer" >
@@ -49,10 +49,12 @@ import match from '../../assets/linkBlack.png';
4949/* eslint-disable object-curly-newline */
5050/* eslint-disable consistent-return */
5151/* eslint-disable max-len */
52+ /* eslint-disable no-await-in-loop */
53+ /* eslint-disable prefer-destructuring */
5254
5355export default {
5456 data : () => ({
55- notify: true ,
57+ notify: false ,
5658 // notifications: [
5759 // { content: 'Samantha liked you', is_seen: false, type: 'like', id: 1, link_to: 'google.com' },
5860 // { content: 'Bae liked you', id: 2, is_seen: false, type: 'dislike', link_to: 'google.com' },
@@ -69,7 +71,20 @@ export default {
6971 showNotifications: false ,
7072 }),
7173 methods: {
72- toggle () {
74+ async makeNotificationsSeen () {
75+ const length = this .notifications .length ;
76+ for (let i = 0 ; i < length; i += 1 ) {
77+ if (! this .notifications [i].is_seen ) {
78+ await this .$http .post (` /notifications/read/${ this .notifications [i].id } ` );
79+ this .notifications [i].is_seen = 1 ;
80+ }
81+ }
82+ },
83+ async toggle () {
84+ if (this .showNotifications ) {
85+ this .notify = false ;
86+ await this .makeNotificationsSeen ();
87+ }
7388 this .showNotifications = ! this .showNotifications ;
7489 },
7590 close (event ) {
@@ -119,7 +134,7 @@ export default {
119134 },
120135 async beforeMount () {
121136 await this .fetchNotifications ();
122- await this .newNotificationCheck ();
137+ // await this.newNotificationCheck();
123138 await this .fetchNewNotifications ();
124139 },
125140};
0 commit comments