mirror of
https://github.com/dbeaver/cloudbeaver.git
synced 2026-09-24 16:04:36 +08:00
fix(core-events): CB-217 throw first
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user