Skip to content

Commit 0ce2e10

Browse files
committed
Add notification icon logging
1 parent b5c32c9 commit 0ce2e10

File tree

4 files changed

+35
-18
lines changed

4 files changed

+35
-18
lines changed

gui/src/main/index.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1036,7 +1036,8 @@ class ApplicationMain
10361036
return shell.openExternal(url);
10371037
}
10381038
};
1039-
public showNotificationIcon = (value: boolean) => this.userInterface?.showNotificationIcon(value);
1039+
public showNotificationIcon = (value: boolean, reason?: string) =>
1040+
this.userInterface?.showNotificationIcon(value, reason);
10401041

10411042
// NotificationSender
10421043
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)