Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions web/components/Notifications/Indicator.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -42,12 +42,12 @@ const icon = computed<{ component: Component; color: string } | null>(() => {
<div class="relative">
<BellIcon class="w-6 h-6 text-header-text-primary" />
<div
v-if="indicatorLevel === 'UNREAD'"
v-if="!seen && indicatorLevel === 'UNREAD'"
class="absolute top-0 right-0 size-2.5 rounded-full border border-neutral-800 bg-unraid-green"
/>
<component
:is="icon.component"
v-else-if="icon && indicatorLevel"
v-else-if="!seen && icon && indicatorLevel"
:class="cn('absolute -top-1 -right-1 size-4 rounded-full', icon.color)"
/>
</div>
Expand Down
23 changes: 21 additions & 2 deletions web/components/Notifications/Sidebar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
</script>

<template>
<Sheet>
<SheetTrigger @click="determineTeleportTarget">
<SheetTrigger @click="prepareToViewNotifications">
<span class="sr-only">Notifications</span>
<NotificationsIndicator :overview="overview" />
<NotificationsIndicator :overview="overview" :seen="hasSeenNotifications" />
</SheetTrigger>
<SheetContent
:to="teleportTarget"
Expand Down
Loading