Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified assets/images/tray-error.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/images/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/tray-offline.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions src/main/icons.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ describe('main/icons.ts', () => {
'assets/images/tray-idle-white.png',
);

expect(TrayIcons.offline).toContain('assets/images/tray-offline.png');

expect(TrayIcons.error).toContain('assets/images/tray-error.png');
});
});
1 change: 1 addition & 0 deletions src/main/icons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export const TrayIcons = {
active: getIconPath('tray-active.png'),
idle: getIconPath('tray-idleTemplate.png'),
idleAlternate: getIconPath('tray-idle-white.png'),
offline: getIconPath('tray-offline.png'),
error: getIconPath('tray-error.png'),
};

Expand Down
10 changes: 10 additions & 0 deletions src/main/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
type BrowserWindowConstructorOptions,
globalShortcut,
nativeTheme,
net,
safeStorage,
shell,
} from 'electron';
Expand Down Expand Up @@ -151,6 +152,11 @@ app.whenReady().then(async () => {

onMainEvent(EVENTS.UPDATE_ICON_COLOR, (_, notificationsCount: number) => {
if (!mb.tray.isDestroyed()) {
if (!net.isOnline()) {
setOfflineIcon();
return;
}

if (notificationsCount < 0) {
setErrorIcon();
return;
Expand Down Expand Up @@ -232,6 +238,10 @@ function setActiveIcon() {
}
}

function setOfflineIcon() {
mb.tray.setImage(TrayIcons.offline);
}

function setErrorIcon() {
mb.tray.setImage(TrayIcons.error);
}
Expand Down