mirror of
https://github.com/unraid/api.git
synced 2026-01-02 06:30:02 -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]);
|
const notification = await this.loadNotificationFile(path, NotificationType[type]);
|
||||||
this.increment(notification.importance, NotificationsService.overview[type.toLowerCase()]);
|
this.increment(notification.importance, NotificationsService.overview[type.toLowerCase()]);
|
||||||
|
|
||||||
this.publishOverview();
|
if (type === NotificationType.UNREAD) {
|
||||||
pubsub.publish(PUBSUB_CHANNEL.NOTIFICATION_ADDED, {
|
this.publishOverview();
|
||||||
notificationAdded: notification,
|
pubsub.publish(PUBSUB_CHANNEL.NOTIFICATION_ADDED, {
|
||||||
});
|
notificationAdded: notification,
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -42,6 +42,12 @@ const { onResult: onNotificationAdded } = useSubscription(notificationAddedSubsc
|
|||||||
onNotificationAdded(({ data }) => {
|
onNotificationAdded(({ data }) => {
|
||||||
if (!data) return;
|
if (!data) return;
|
||||||
const notif = useFragment(NOTIFICATION_FRAGMENT, data.notificationAdded);
|
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']> = {
|
const funcMapping: Record<Importance, (typeof globalThis)['toast']['info' | 'error' | 'warning']> = {
|
||||||
[Importance.Alert]: globalThis.toast.error,
|
[Importance.Alert]: globalThis.toast.error,
|
||||||
@@ -51,10 +57,12 @@ onNotificationAdded(({ data }) => {
|
|||||||
const toast = funcMapping[notif.importance];
|
const toast = funcMapping[notif.importance];
|
||||||
const createOpener = () => ({ label: 'Open', onClick: () => location.assign(notif.link as string) });
|
const createOpener = () => ({ label: 'Open', onClick: () => location.assign(notif.link as string) });
|
||||||
|
|
||||||
toast(notif.title, {
|
requestAnimationFrame(() =>
|
||||||
description: notif.subject,
|
toast(notif.title, {
|
||||||
action: notif.link ? createOpener() : undefined,
|
description: notif.subject,
|
||||||
});
|
action: notif.link ? createOpener() : undefined,
|
||||||
|
})
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
const overview = computed(() => {
|
const overview = computed(() => {
|
||||||
|
|||||||
Reference in New Issue
Block a user