summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorOskar Nyberg <oskar@mullvad.net>2024-03-21 10:36:39 +0100
committerOskar Nyberg <oskar@mullvad.net>2024-03-21 10:36:39 +0100
commitb469ef65c4c8bde6b2dcf5f55f7fa4a8233d22d8 (patch)
tree7358f6934c8d8d95d7d0dd43a44f2c5dc531bf35
parent7c0baef67673bafd8195ae192e6ac90a63afb98f (diff)
parent0ce2e108b1030b7375e8962e76ee18ef938d53bc (diff)
downloadmullvadvpn-b469ef65c4c8bde6b2dcf5f55f7fa4a8233d22d8.tar.xz
mullvadvpn-b469ef65c4c8bde6b2dcf5f55f7fa4a8233d22d8.zip
Merge branch 'notification-dot-visible-when-there-are-no-notification-des-686'
-rw-r--r--gui/src/main/account.ts2
-rw-r--r--gui/src/main/index.ts11
-rw-r--r--gui/src/main/notification-controller.ts33
-rw-r--r--gui/src/main/tray-icon-controller.ts13
-rw-r--r--gui/src/main/user-interface.ts4
5 files changed, 45 insertions, 18 deletions
diff --git a/gui/src/main/account.ts b/gui/src/main/account.ts
index acad9697e5..ca4f1f9968 100644
--- a/gui/src/main/account.ts
+++ b/gui/src/main/account.ts
@@ -120,6 +120,8 @@ export default class Account {
}
public handleDeviceEvent(deviceEvent: DeviceEvent) {
+ this.delegate.closeNotificationsInCategory(SystemNotificationCategory.expiry);
+
this.deviceStateValue = deviceEvent.deviceState;
switch (deviceEvent.deviceState.type) {
diff --git a/gui/src/main/index.ts b/gui/src/main/index.ts
index 92d51dba69..59f81141cd 100644
--- a/gui/src/main/index.ts
+++ b/gui/src/main/index.ts
@@ -487,6 +487,10 @@ class ApplicationMain
log.info('Connected to the daemon');
+ this.notificationController.closeNotificationsInCategory(
+ SystemNotificationCategory.tunnelState,
+ );
+
// subscribe to events
try {
this.daemonEventListener = this.subscribeEvents();
@@ -623,6 +627,10 @@ class ApplicationMain
// Reset the daemon event listener since it's going to be invalidated on disconnect
this.daemonEventListener = undefined;
+ this.notificationController.closeNotificationsInCategory(
+ SystemNotificationCategory.tunnelState,
+ );
+
if (this.tunnelState.tunnelState.state !== 'disconnected') {
this.notificationController.notifyDaemonDisconnected(
this.userInterface?.isWindowVisible() ?? false,
@@ -1028,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) {