Skip to content

Commit f983c83

Browse files
committed
prevent visiting current route on notification click
1 parent 6f1a6d5 commit f983c83

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

frontend/src/components/shared/NavBarBell.vue

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,13 @@
2828
'font-bold': !notification.is_seen,}"
2929
v-for="(notification, index) in notifications" :key="index + notification.is_seen.toString()">
3030

31-
<router-link
31+
<div
3232
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)"
3534
class="py-4 flex items-center word-break cursor-pointer">
3635
<img v-bind:src="getImage(notification.type)" class="w-4 h-4">
3736
<h1 class="ml-4">{{notification.content}}</h1>
38-
</router-link>
37+
</div>
3938
<div v-else class="py-4 flex items-center word-break">
4039
<img v-bind:src="getImage(notification.type)" class="w-4 h-4">
4140
<h1 class="ml-4">{{notification.content}}</h1>
@@ -70,11 +69,14 @@ export default {
7069
fetchNotificationsIntervalId: null,
7170
}),
7271
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}`);
7679
}
77-
return `/${link}`;
7880
},
7981
async makeNotificationsSeen() {
8082
const length = this.notifications.length;

0 commit comments

Comments
 (0)