From fc20733dde083711bc55d71900fbfb1e0a7eabd5 Mon Sep 17 00:00:00 2001 From: Roman Date: Wed, 7 Oct 2020 14:01:20 +0300 Subject: [PATCH] fix: refresh icon after turning on/off + switching dark-mode Signed-off-by: Roman --- src/main/tray.ts | 5 ++--- src/main/window-manager.ts | 5 +++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/tray.ts b/src/main/tray.ts index f9fa7414ba..49316f38fb 100644 --- a/src/main/tray.ts +++ b/src/main/tray.ts @@ -31,9 +31,8 @@ nativeTheme.on("updated", async () => { }); export async function initTray(windowManager: WindowManager) { - if (!trayIcon) { - trayIcon = await createTrayIconFromSvg(); - } + trayIcon = await createTrayIconFromSvg(); // generate icon once on tray activation + const dispose = autorun(() => { const menu = createTrayMenu(windowManager); buildTray(trayIcon, menu); diff --git a/src/main/window-manager.ts b/src/main/window-manager.ts index 641483e15e..cd2a1af98f 100644 --- a/src/main/window-manager.ts +++ b/src/main/window-manager.ts @@ -59,8 +59,9 @@ export class WindowManager { this.disposers.trayAutoBind = reaction(() => userStore.preferences.trayEnabled, async isEnabled => { if (isEnabled) { this.disposers.trayAutoUpdater = await initTray(this); - } else { - this.disposers?.trayAutoUpdater(); + } else if (this.disposers.trayAutoUpdater) { + this.disposers.trayAutoUpdater(); + this.disposers.trayAutoUpdater = null; } }, { fireImmediately: true