From 45ff2ca4def850cd589c3b1a5fe323ae0d8b0d8d Mon Sep 17 00:00:00 2001 From: Wroud Date: Mon, 5 Oct 2020 02:28:47 +0300 Subject: [PATCH] fix(core-events): CB-217 throw first --- .../core-events/src/NotificationService.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) 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);