react to all noti adds not just active noti add

This commit is contained in:
David Tsay 2023-09-20 10:14:03 -07:00
parent 64763f5c24
commit 1854ca4b6f
2 changed files with 13 additions and 10 deletions

View File

@ -323,24 +323,25 @@ export default class NotificationAPI extends EventEmitter {
notification = this._createNotification(notificationModel);
this.notifications.push(notification);
this.emit('add', notification);
this._setHighestSeverity();
/*
Check if there is already an active (ie. visible) notification
*/
Check if there is already an active (ie. visible) notification
*/
if (!this.activeNotification && !notification?.model?.options?.minimized) {
this._setActiveNotification(notification);
} else if (!this.activeTimeout) {
/*
If there is already an active notification, time it out. If it's
already got a timeout in progress (either because it has had
timeout forced because of a queue of messages, or it had an
autodismiss specified), leave it to run. Otherwise force a
timeout.
If there is already an active notification, time it out. If it's
already got a timeout in progress (either because it has had
timeout forced because of a queue of messages, or it had an
autodismiss specified), leave it to run. Otherwise force a
timeout.
This notification has been added to queue and will be
serviced as soon as possible.
*/
This notification has been added to queue and will be
serviced as soon as possible.
*/
this.activeTimeout = setTimeout(() => {
this._dismissOrMinimize(activeNotification);
}, DEFAULT_AUTO_DISMISS_TIMEOUT);

View File

@ -70,10 +70,12 @@ export default {
},
mounted() {
this.openmct.notifications.on('notification', this.updateNotifications);
this.openmct.notifications.on('add', this.updateNotifications);
this.openmct.notifications.on('dismiss-all', this.updateNotifications);
},
unmounted() {
this.openmct.notifications.off('notification', this.updateNotifications);
this.openmct.notifications.off('add', this.updateNotifications);
this.openmct.notifications.off('dismiss-all', this.updateNotifications);
},
methods: {