diff --git a/webapp/packages/core-events/src/NotificationService.ts b/webapp/packages/core-events/src/NotificationService.ts index 19e20324ac..308bce0466 100644 --- a/webapp/packages/core-events/src/NotificationService.ts +++ b/webapp/packages/core-events/src/NotificationService.ts @@ -29,6 +29,13 @@ export class NotificationService { TSource> = Record>( options: INotificationOptions, type: ENotificationType ) { + if (options.persistent) { + const persistentNotifications = this.notificationList.values.filter(value => value.persistent); + if (persistentNotifications.length >= this.settings.settings.getValue('maxPersistentAllow')) { + throw new Error(`You cannot create more than ${this.settings.settings.getValue('maxPersistentAllow')} persistent notification`); + } + } + const id = this.notificationNextId++; const notification: INotification = { @@ -45,13 +52,6 @@ export class NotificationService { showDetails: this.showDetails.bind(this, id), }; - if (notification.persistent) { - const persistentNotifications = this.notificationList.values.filter(value => value.persistent); - if (persistentNotifications.length >= this.settings.settings.getValue('maxPersistentAllow')) { - throw new Error(`You cannot create more than ${this.settings.settings.getValue('maxPersistentAllow')} persistent notification`); - } - } - this.notificationList.addValue(notification); const filteredNotificationList = this.notificationList.values.filter(notification => !notification.persistent);