mirror of
https://github.com/unraid/api.git
synced 2025-12-31 13:39:52 -06:00
fix: only toast unread notifications, not archived ones
This commit is contained in:
committed by
Eli Bosley
parent
ad32cffd75
commit
8251c6f2d3
@@ -103,10 +103,12 @@ export class NotificationsService {
|
||||
const notification = await this.loadNotificationFile(path, NotificationType[type]);
|
||||
this.increment(notification.importance, NotificationsService.overview[type.toLowerCase()]);
|
||||
|
||||
this.publishOverview();
|
||||
pubsub.publish(PUBSUB_CHANNEL.NOTIFICATION_ADDED, {
|
||||
notificationAdded: notification,
|
||||
});
|
||||
if (type === NotificationType.UNREAD) {
|
||||
this.publishOverview();
|
||||
pubsub.publish(PUBSUB_CHANNEL.NOTIFICATION_ADDED, {
|
||||
notificationAdded: notification,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -42,6 +42,12 @@ const { onResult: onNotificationAdded } = useSubscription(notificationAddedSubsc
|
||||
onNotificationAdded(({ data }) => {
|
||||
if (!data) return;
|
||||
const notif = useFragment(NOTIFICATION_FRAGMENT, data.notificationAdded);
|
||||
if (notif.type !== NotificationType.Unread) return;
|
||||
// probably smart to leave this log outside the if-block for the initial release
|
||||
console.log('incoming notification', notif);
|
||||
if (!globalThis.toast) {
|
||||
return;
|
||||
}
|
||||
|
||||
const funcMapping: Record<Importance, (typeof globalThis)['toast']['info' | 'error' | 'warning']> = {
|
||||
[Importance.Alert]: globalThis.toast.error,
|
||||
@@ -51,10 +57,12 @@ onNotificationAdded(({ data }) => {
|
||||
const toast = funcMapping[notif.importance];
|
||||
const createOpener = () => ({ label: 'Open', onClick: () => location.assign(notif.link as string) });
|
||||
|
||||
toast(notif.title, {
|
||||
description: notif.subject,
|
||||
action: notif.link ? createOpener() : undefined,
|
||||
});
|
||||
requestAnimationFrame(() =>
|
||||
toast(notif.title, {
|
||||
description: notif.subject,
|
||||
action: notif.link ? createOpener() : undefined,
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
const overview = computed(() => {
|
||||
|
||||
Reference in New Issue
Block a user