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