Skip to content

Commit cc59be6

Browse files
pujitmelibosley
authored andcommitted
fix: only toast unread notifications, not archived ones
1 parent 43e6639 commit cc59be6

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

api/src/unraid-api/graph/resolvers/notifications/notifications.service.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,12 @@ export class NotificationsService {
103103
const notification = await this.loadNotificationFile(path, NotificationType[type]);
104104
this.increment(notification.importance, NotificationsService.overview[type.toLowerCase()]);
105105

106-
this.publishOverview();
107-
pubsub.publish(PUBSUB_CHANNEL.NOTIFICATION_ADDED, {
108-
notificationAdded: notification,
109-
});
106+
if (type === NotificationType.UNREAD) {
107+
this.publishOverview();
108+
pubsub.publish(PUBSUB_CHANNEL.NOTIFICATION_ADDED, {
109+
notificationAdded: notification,
110+
});
111+
}
110112
}
111113

112114
/**

web/components/Notifications/Sidebar.vue

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@ const { onResult: onNotificationAdded } = useSubscription(notificationAddedSubsc
4242
onNotificationAdded(({ data }) => {
4343
if (!data) return;
4444
const notif = useFragment(NOTIFICATION_FRAGMENT, data.notificationAdded);
45+
if (notif.type !== NotificationType.Unread) return;
46+
// probably smart to leave this log outside the if-block for the initial release
47+
console.log('incoming notification', notif);
48+
if (!globalThis.toast) {
49+
return;
50+
}
4551
4652
const funcMapping: Record<Importance, (typeof globalThis)['toast']['info' | 'error' | 'warning']> = {
4753
[Importance.Alert]: globalThis.toast.error,
@@ -51,10 +57,12 @@ onNotificationAdded(({ data }) => {
5157
const toast = funcMapping[notif.importance];
5258
const createOpener = () => ({ label: 'Open', onClick: () => location.assign(notif.link as string) });
5359
54-
toast(notif.title, {
55-
description: notif.subject,
56-
action: notif.link ? createOpener() : undefined,
57-
});
60+
requestAnimationFrame(() =>
61+
toast(notif.title, {
62+
description: notif.subject,
63+
action: notif.link ? createOpener() : undefined,
64+
})
65+
);
5866
});
5967
6068
const overview = computed(() => {

0 commit comments

Comments
 (0)