diff --git a/web/components/Notifications/Indicator.vue b/web/components/Notifications/Indicator.vue index 44bd99430..9012b8917 100644 --- a/web/components/Notifications/Indicator.vue +++ b/web/components/Notifications/Indicator.vue @@ -3,7 +3,7 @@ import { BellIcon, ExclamationTriangleIcon, ShieldExclamationIcon } from '@heroi import { cn } from '~/components/shadcn/utils'; import { Importance, type OverviewQuery } from '~/composables/gql/graphql'; -const props = defineProps<{ overview?: OverviewQuery['notifications']['overview'] }>(); +const props = defineProps<{ overview?: OverviewQuery['notifications']['overview'], seen?: boolean }>(); const indicatorLevel = computed(() => { if (!props.overview?.unread) { @@ -42,12 +42,12 @@ const icon = computed<{ component: Component; color: string } | null>(() => {
diff --git a/web/components/Notifications/Sidebar.vue b/web/components/Notifications/Sidebar.vue index 120733bcf..86299d79f 100644 --- a/web/components/Notifications/Sidebar.vue +++ b/web/components/Notifications/Sidebar.vue @@ -39,13 +39,32 @@ const overview = computed(() => { } return result.value.notifications.overview; }); + +/** whether user has viewed their notifications */ +const hasSeenNotifications = ref(false); + +// renews unseen state when new notifications arrive +watch( + () => overview.value?.unread, + (newVal, oldVal) => { + if (!newVal || !oldVal) return; + if (newVal.total > oldVal.total) { + hasSeenNotifications.value = false; + } + } +); + +const prepareToViewNotifications = () => { + determineTeleportTarget(); + hasSeenNotifications.value = true; +};