|
28 | 28 | 'font-bold': !notification.is_seen,}" |
29 | 29 | v-for="(notification, index) in notifications" :key="index + notification.is_seen.toString()"> |
30 | 30 |
|
31 | | - <router-link |
| 31 | + <div |
32 | 32 | v-if="notification.link_to" |
33 | | - v-bind:to="getLinkTo(notification.type, notification.link_to)" |
34 | | - v-on:click.native="toggle" |
| 33 | + v-on:click="linkTo(notification.type, notification.link_to)" |
35 | 34 | class="py-4 flex items-center word-break cursor-pointer"> |
36 | 35 | <img v-bind:src="getImage(notification.type)" class="w-4 h-4"> |
37 | 36 | <h1 class="ml-4">{{notification.content}}</h1> |
38 | | - </router-link> |
| 37 | + </div> |
39 | 38 | <div v-else class="py-4 flex items-center word-break"> |
40 | 39 | <img v-bind:src="getImage(notification.type)" class="w-4 h-4"> |
41 | 40 | <h1 class="ml-4">{{notification.content}}</h1> |
@@ -70,11 +69,14 @@ export default { |
70 | 69 | fetchNotificationsIntervalId: null, |
71 | 70 | }), |
72 | 71 | methods: { |
73 | | - getLinkTo(type, link) { |
74 | | - if (type === 'match' || type === 'message' || type === 'message_like') { |
75 | | - return '/matches'; |
| 72 | + async linkTo(type, link) { |
| 73 | + await this.toggle(); |
| 74 | + if ((type === 'match' || type === 'message' || type === 'message_like') && this.$route.path !== '/matches') { |
| 75 | + await this.$router.push('/matches'); |
| 76 | + } |
| 77 | + if (this.$route.path !== `/${link}`) { |
| 78 | + await this.$router.push(`/${link}`); |
76 | 79 | } |
77 | | - return `/${link}`; |
78 | 80 | }, |
79 | 81 | async makeNotificationsSeen() { |
80 | 82 | const length = this.notifications.length; |
|
0 commit comments