File tree Expand file tree Collapse file tree 2 files changed +18
-8
lines changed
api/src/unraid-api/graph/resolvers/notifications
web/components/Notifications Expand file tree Collapse file tree 2 files changed +18
-8
lines changed Original file line number Diff line number Diff 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 /**
Original file line number Diff line number Diff line change @@ -42,6 +42,12 @@ const { onResult: onNotificationAdded } = useSubscription(notificationAddedSubsc
4242onNotificationAdded (({ 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
6068const overview = computed (() => {
You can’t perform that action at this time.
0 commit comments