diff --git a/public/site/plugins/notifications/user-methods/read.php b/public/site/plugins/notifications/user-methods/read.php index 4de14df..cb61db0 100644 --- a/public/site/plugins/notifications/user-methods/read.php +++ b/public/site/plugins/notifications/user-methods/read.php @@ -8,6 +8,7 @@ return function($notificationId) { $newNotification = null; foreach ($notifications as $key => $notification) { + if (!isset($notification['id'])) continue; if ($notification['id'] === $notificationId) { $notifications[$key]['isRead'] = true; $newNotification = $notifications[$key]; diff --git a/src/components/Menu.vue b/src/components/Menu.vue index 3b40c06..8139b17 100644 --- a/src/components/Menu.vue +++ b/src/components/Menu.vue @@ -116,7 +116,7 @@ const { page } = storeToRefs(usePageStore()); const unreadNotificationsCount = computed(() => { if (!user.value) return undefined; - const count = user.value.notifications.map( + const count = user.value.notifications.filter( (notification) => notification.isRead ).length; if (count === 0) return undefined; diff --git a/src/views/Notifications.vue b/src/views/Notifications.vue index e6cc4b1..a359917 100644 --- a/src/views/Notifications.vue +++ b/src/views/Notifications.vue @@ -174,12 +174,14 @@ function readAll() { function read(notification) { if (!notification.isRead) { - api.readNotification(notification.id).then((res) => { - console.log(res); - // router.push(toPath(notification.location.href)); - }); + console.log(notification); + api + .readNotification(notification.id) + .then((res) => { + router.push(toPath(notification.location.href)); + }) + .catch((err) => console.log(err)); } - router.push(toPath(notification.location.href)); } function toPath(string) {