Skip to content

Commit b469ef6

Browse files
committed
Merge branch 'notification-dot-visible-when-there-are-no-notification-des-686'
2 parents 7c0baef + 0ce2e10 commit b469ef6

5 files changed

+45
-18
lines changed

gui/src/main/account.ts

+2
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,8 @@ export default class Account {
120120
}
121121

122122
public handleDeviceEvent(deviceEvent: DeviceEvent) {
123+
this.delegate.closeNotificationsInCategory(SystemNotificationCategory.expiry);
124+
123125
this.deviceStateValue = deviceEvent.deviceState;
124126

125127
switch (deviceEvent.deviceState.type) {

gui/src/main/index.ts

+10-1
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,10 @@ class ApplicationMain
487487

488488
log.info('Connected to the daemon');
489489

490+
this.notificationController.closeNotificationsInCategory(
491+
SystemNotificationCategory.tunnelState,
492+
);
493+
490494
// subscribe to events
491495
try {
492496
this.daemonEventListener = this.subscribeEvents();
@@ -623,6 +627,10 @@ class ApplicationMain
623627
// Reset the daemon event listener since it's going to be invalidated on disconnect
624628
this.daemonEventListener = undefined;
625629

630+
this.notificationController.closeNotificationsInCategory(
631+
SystemNotificationCategory.tunnelState,
632+
);
633+
626634
if (this.tunnelState.tunnelState.state !== 'disconnected') {
627635
this.notificationController.notifyDaemonDisconnected(
628636
this.userInterface?.isWindowVisible() ?? false,
@@ -1028,7 +1036,8 @@ class ApplicationMain
10281036
return shell.openExternal(url);
10291037
}
10301038
};
1031-
public showNotificationIcon = (value: boolean) => this.userInterface?.showNotificationIcon(value);
1039+
public showNotificationIcon = (value: boolean, reason?: string) =>
1040+
this.userInterface?.showNotificationIcon(value, reason);
10321041

10331042
// NotificationSender
10341043
public notify = (notification: SystemNotification) => {

gui/src/main/notification-controller.ts

+19-14
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,14 @@ export interface NotificationSender {
3434
export interface NotificationControllerDelegate {
3535
openApp(): void;
3636
openLink(url: string, withAuth?: boolean): Promise<void>;
37-
showNotificationIcon(value: boolean): void;
37+
/**
38+
* We have experienced issues where the
39+
* notification dot wasn't removed and logging the reason for it to be showing we can narrow the
40+
* causes down.
41+
*
42+
* @param reason Used for debug purposes, it is currently all relevant notification messages..
43+
*/
44+
showNotificationIcon(value: boolean, reason?: string): void;
3845
}
3946

4047
enum NotificationSuppressReason {
@@ -278,21 +285,19 @@ export default class NotificationController {
278285
}
279286

280287
private updateNotificationIcon() {
281-
for (const notification of this.activeNotifications) {
282-
if (notification.specification.severity >= SystemNotificationSeverityType.medium) {
283-
this.notificationControllerDelegate.showNotificationIcon(true);
284-
return;
285-
}
286-
}
288+
const activeNotifications = [...this.activeNotifications].map(
289+
(notification) => notification.specification,
290+
);
291+
const notifications = [...activeNotifications, ...this.dismissedNotifications].filter(
292+
(notification) => notification.severity >= SystemNotificationSeverityType.medium,
293+
);
287294

288-
for (const notification of this.dismissedNotifications) {
289-
if (notification.severity >= SystemNotificationSeverityType.medium) {
290-
this.notificationControllerDelegate.showNotificationIcon(true);
291-
return;
292-
}
295+
if (notifications.length > 0) {
296+
const reason = notifications.map((notification) => `"${notification.message}"`).join(',');
297+
this.notificationControllerDelegate.showNotificationIcon(true, reason);
298+
} else {
299+
this.notificationControllerDelegate.showNotificationIcon(false);
293300
}
294-
295-
this.notificationControllerDelegate.showNotificationIcon(false);
296301
}
297302

298303
private evaluateNotification(

gui/src/main/tray-icon-controller.ts

+12-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ export default class TrayIconController {
1919

2020
private updateThrottlePromise?: Promise<void>;
2121

22+
private previousNotificationIconReason?: string;
23+
2224
constructor(
2325
private tray: Tray,
2426
private iconTypeValue: TrayIconType,
@@ -57,7 +59,16 @@ export default class TrayIconController {
5759
void this.updateIconParameters({ monochromatic: monochromaticIcon });
5860
}
5961

60-
public showNotificationIcon(notificationIcon: boolean) {
62+
public showNotificationIcon(notificationIcon: boolean, reason?: string) {
63+
if (reason !== this.previousNotificationIconReason) {
64+
this.previousNotificationIconReason = reason;
65+
if (notificationIcon) {
66+
log.info('Showing notification icon:', reason);
67+
} else {
68+
log.info('Hiding notification icon');
69+
}
70+
}
71+
6172
void this.updateIconParameters({ notification: notificationIcon });
6273
}
6374

gui/src/main/user-interface.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,8 @@ export default class UserInterface implements WindowControllerDelegate {
189189
public updateTrayTheme = () => this.trayIconController?.updateTheme() ?? Promise.resolve();
190190
public setMonochromaticIcon = (value: boolean) =>
191191
this.trayIconController?.setMonochromaticIcon(value);
192-
public showNotificationIcon = (value: boolean) =>
193-
this.trayIconController?.showNotificationIcon(value);
192+
public showNotificationIcon = (value: boolean, reason?: string) =>
193+
this.trayIconController?.showNotificationIcon(value, reason);
194194
public setWindowIcon = (icon: string) => this.windowController.window?.setIcon(icon);
195195

196196
public updateTrayIcon(tunnelState: TunnelState, blockWhenDisconnected: boolean) {

0 commit comments

Comments
 (0)