fix(core-events): CB-217 throw first

This commit is contained in:
Wroud
2020-10-05 02:28:47 +03:00
parent bd66fada51
commit 45ff2ca4de
@@ -29,6 +29,13 @@ export class NotificationService {
TSource> = Record<string, any>>(
options: INotificationOptions<TSource, TProps>, 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<TSource, TProps> = {
@@ -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);