diff options
| author | Oskar Nyberg <oskar@mullvad.net> | 2022-11-30 15:00:30 +0100 |
|---|---|---|
| committer | Oskar Nyberg <oskar@mullvad.net> | 2023-02-09 10:39:26 +0100 |
| commit | b00d0b5a176c4d8dcd403a60395c5a1087c42cdd (patch) | |
| tree | 188a7c4eeb204a1e81cb9504a8c59b10a85355ea /gui/src/main | |
| parent | 9bc388cd020d0e4fc675e02b20522f31c2464885 (diff) | |
| download | mullvadvpn-b00d0b5a176c4d8dcd403a60395c5a1087c42cdd.tar.xz mullvadvpn-b00d0b5a176c4d8dcd403a60395c5a1087c42cdd.zip | |
Add notification categories
Diffstat (limited to 'gui/src/main')
| -rw-r--r-- | gui/src/main/notification-controller.ts | 26 |
1 files changed, 10 insertions, 16 deletions
diff --git a/gui/src/main/notification-controller.ts b/gui/src/main/notification-controller.ts index 33149bcae8..cf703e431c 100644 --- a/gui/src/main/notification-controller.ts +++ b/gui/src/main/notification-controller.ts @@ -28,8 +28,8 @@ export interface NotificationControllerDelegate { export default class NotificationController { private lastTunnelStateAnnouncement?: { body: string; notification: Notification }; private reconnecting = false; - private presentedNotifications: { [key: string]: boolean } = {}; - private pendingNotifications: Notification[] = []; + private previousNotifications: { [key: string]: boolean } = {}; + private activeNotifications: Notification[] = []; private notificationTitle = process.platform === 'linux' ? app.name : ''; private notificationIcon?: NativeImage; @@ -91,7 +91,7 @@ export default class NotificationController { } public cancelPendingNotifications() { - for (const notification of this.pendingNotifications) { + for (const notification of this.activeNotifications) { notification.close(); } } @@ -109,7 +109,7 @@ export default class NotificationController { this.evaluateNotification(systemNotification, isWindowVisible, areSystemNotificationsEnabled) ) { const notification = this.createNotification(systemNotification); - this.addPendingNotification(notification); + this.addActiveNotification(notification); notification.show(); return notification; @@ -188,19 +188,13 @@ export default class NotificationController { } } - private addPendingNotification(notification: Notification) { - notification.on('close', () => { - this.removePendingNotification(notification); - }); - - this.pendingNotifications.push(notification); + private addActiveNotification(notification: Notification) { + notification.on('close', () => this.removeActiveNotification(notification)); + this.activeNotifications.push(notification); } - private removePendingNotification(notification: Notification) { - const index = this.pendingNotifications.indexOf(notification); - if (index !== -1) { - this.pendingNotifications.splice(index, 1); - } + private removeActiveNotification(notification: Notification) { + this.activeNotifications = this.activeNotifications.filter((value) => value !== notification); } private evaluateNotification( @@ -223,7 +217,7 @@ export default class NotificationController { } private suppressDueToAlreadyPresented(notification: SystemNotification) { - const presented = this.presentedNotifications; + const presented = this.previousNotifications; if (notification.presentOnce?.value) { if (presented[notification.presentOnce.name]) { return true; |
