diff options
| author | Oskar Nyberg <oskar@mullvad.net> | 2024-03-20 08:37:50 +0100 |
|---|---|---|
| committer | Oskar Nyberg <oskar@mullvad.net> | 2024-03-21 10:35:39 +0100 |
| commit | 0ce2e108b1030b7375e8962e76ee18ef938d53bc (patch) | |
| tree | 7358f6934c8d8d95d7d0dd43a44f2c5dc531bf35 | |
| parent | b5c32c96ac8994964e214b0018cba630811a532a (diff) | |
| download | mullvadvpn-0ce2e108b1030b7375e8962e76ee18ef938d53bc.tar.xz mullvadvpn-0ce2e108b1030b7375e8962e76ee18ef938d53bc.zip | |
Add notification icon logging
| -rw-r--r-- | gui/src/main/index.ts | 3 | ||||
| -rw-r--r-- | gui/src/main/notification-controller.ts | 33 | ||||
| -rw-r--r-- | gui/src/main/tray-icon-controller.ts | 13 | ||||
| -rw-r--r-- | gui/src/main/user-interface.ts | 4 |
4 files changed, 35 insertions, 18 deletions
diff --git a/gui/src/main/index.ts b/gui/src/main/index.ts index 0a01854fde..59f81141cd 100644 --- a/gui/src/main/index.ts +++ b/gui/src/main/index.ts @@ -1036,7 +1036,8 @@ class ApplicationMain return shell.openExternal(url); } }; - public showNotificationIcon = (value: boolean) => this.userInterface?.showNotificationIcon(value); + public showNotificationIcon = (value: boolean, reason?: string) => + this.userInterface?.showNotificationIcon(value, reason); // NotificationSender public notify = (notification: SystemNotification) => { diff --git a/gui/src/main/notification-controller.ts b/gui/src/main/notification-controller.ts index 3639ac25eb..925bff0812 100644 --- a/gui/src/main/notification-controller.ts +++ b/gui/src/main/notification-controller.ts @@ -34,7 +34,14 @@ export interface NotificationSender { export interface NotificationControllerDelegate { openApp(): void; openLink(url: string, withAuth?: boolean): Promise<void>; - showNotificationIcon(value: boolean): void; + /** + * We have experienced issues where the + * notification dot wasn't removed and logging the reason for it to be showing we can narrow the + * causes down. + * + * @param reason Used for debug purposes, it is currently all relevant notification messages.. + */ + showNotificationIcon(value: boolean, reason?: string): void; } enum NotificationSuppressReason { @@ -278,21 +285,19 @@ export default class NotificationController { } private updateNotificationIcon() { - for (const notification of this.activeNotifications) { - if (notification.specification.severity >= SystemNotificationSeverityType.medium) { - this.notificationControllerDelegate.showNotificationIcon(true); - return; - } - } + const activeNotifications = [...this.activeNotifications].map( + (notification) => notification.specification, + ); + const notifications = [...activeNotifications, ...this.dismissedNotifications].filter( + (notification) => notification.severity >= SystemNotificationSeverityType.medium, + ); - for (const notification of this.dismissedNotifications) { - if (notification.severity >= SystemNotificationSeverityType.medium) { - this.notificationControllerDelegate.showNotificationIcon(true); - return; - } + if (notifications.length > 0) { + const reason = notifications.map((notification) => `"${notification.message}"`).join(','); + this.notificationControllerDelegate.showNotificationIcon(true, reason); + } else { + this.notificationControllerDelegate.showNotificationIcon(false); } - - this.notificationControllerDelegate.showNotificationIcon(false); } private evaluateNotification( diff --git a/gui/src/main/tray-icon-controller.ts b/gui/src/main/tray-icon-controller.ts index df474bdc1b..ff7300b1e6 100644 --- a/gui/src/main/tray-icon-controller.ts +++ b/gui/src/main/tray-icon-controller.ts @@ -19,6 +19,8 @@ export default class TrayIconController { private updateThrottlePromise?: Promise<void>; + private previousNotificationIconReason?: string; + constructor( private tray: Tray, private iconTypeValue: TrayIconType, @@ -57,7 +59,16 @@ export default class TrayIconController { void this.updateIconParameters({ monochromatic: monochromaticIcon }); } - public showNotificationIcon(notificationIcon: boolean) { + public showNotificationIcon(notificationIcon: boolean, reason?: string) { + if (reason !== this.previousNotificationIconReason) { + this.previousNotificationIconReason = reason; + if (notificationIcon) { + log.info('Showing notification icon:', reason); + } else { + log.info('Hiding notification icon'); + } + } + void this.updateIconParameters({ notification: notificationIcon }); } diff --git a/gui/src/main/user-interface.ts b/gui/src/main/user-interface.ts index ac308adc01..3d6e04f8e7 100644 --- a/gui/src/main/user-interface.ts +++ b/gui/src/main/user-interface.ts @@ -189,8 +189,8 @@ export default class UserInterface implements WindowControllerDelegate { public updateTrayTheme = () => this.trayIconController?.updateTheme() ?? Promise.resolve(); public setMonochromaticIcon = (value: boolean) => this.trayIconController?.setMonochromaticIcon(value); - public showNotificationIcon = (value: boolean) => - this.trayIconController?.showNotificationIcon(value); + public showNotificationIcon = (value: boolean, reason?: string) => + this.trayIconController?.showNotificationIcon(value, reason); public setWindowIcon = (icon: string) => this.windowController.window?.setIcon(icon); public updateTrayIcon(tunnelState: TunnelState, blockWhenDisconnected: boolean) { |
