#34 - fix console error

This commit is contained in:
isUnknown 2024-12-17 14:16:00 +01:00
parent 6b8871784e
commit 0cf26819ce
2 changed files with 15 additions and 11 deletions

View file

@ -39,7 +39,9 @@
:key="mainItem.path"
:class="{ active: isCurrent(mainItem), disabled: mainItem.disabled }"
:data-count="
mainItem.title === 'Notifications' ? notificationCount() : undefined
mainItem.title === 'Notifications'
? unreadNotificationsCount
: undefined
"
>
<router-link
@ -100,7 +102,7 @@
<script setup>
import { storeToRefs } from "pinia";
import { ref } from "vue";
import { computed, ref } from "vue";
import { useProjectsStore } from "../stores/projects";
import { useRoute } from "vue-router";
import { useUserStore } from "../stores/user";
@ -112,6 +114,15 @@ const { user } = storeToRefs(useUserStore());
const { currentProjects, archivedProjects } = storeToRefs(useProjectsStore());
const { page } = storeToRefs(usePageStore());
const unreadNotificationsCount = computed(() => {
if (!user.value) return undefined;
const count = user.value.notifications.map(
(notification) => notification.isRead
).length;
if (count === 0) return undefined;
return count;
});
const mainItems = [
{
title: "Home",
@ -158,14 +169,6 @@ function collapse() {
isExpanded.value = false;
}
}
function notificationCount() {
const count = user.value.notifications.map(
(notification) => notification.isRead
).length;
if (count === 0) return undefined;
return count;
}
</script>
<style>

View file

@ -175,7 +175,8 @@ function readAll() {
function read(notification) {
if (!notification.isRead) {
api.readNotification(notification.id).then((res) => {
router.push(toPath(notification.location.href));
console.log(res);
// router.push(toPath(notification.location.href));
});
}
router.push(toPath(notification.location.href));