diff --git a/src/app/accounts/settings.component.ts b/src/app/accounts/settings.component.ts index 396eb8dd7f..eb0b8b259d 100644 --- a/src/app/accounts/settings.component.ts +++ b/src/app/accounts/settings.component.ts @@ -53,6 +53,7 @@ export class SettingsComponent implements OnInit { alwaysShowDock: boolean; showAlwaysShowDock: boolean = false; openAtLogin: boolean; + requireEnableTray: boolean = false; enableTrayText: string; enableTrayDescText: string; @@ -70,6 +71,9 @@ export class SettingsComponent implements OnInit { private userService: UserService, private cryptoService: CryptoService) { const isMac = this.platformUtilsService.getDevice() === DeviceType.MacOsDesktop; + // Workaround to avoid ghosting trays https://github.com/electron/electron/issues/17622 + this.requireEnableTray = this.platformUtilsService.getDevice() === DeviceType.LinuxDesktop; + const trayKey = isMac ? 'enableMenuBar' : 'enableTray'; this.enableTrayText = this.i18nService.t(trayKey); this.enableTrayDescText = this.i18nService.t(trayKey + 'Desc'); @@ -269,17 +273,40 @@ export class SettingsComponent implements OnInit { } async saveCloseToTray() { + if (this.requireEnableTray) { + this.enableTray = true; + } + await this.storageService.save(ElectronConstants.enableCloseToTrayKey, this.enableCloseToTray); this.callAnalytics('CloseToTray', this.enableCloseToTray); } async saveTray() { + if (this.requireEnableTray && !this.enableTray && (this.startToTray || this.enableCloseToTray)) { + const confirm = await this.platformUtilsService.showDialog( + this.i18nService.t('confirmTrayDesc'), this.i18nService.t('confirmTrayTitle'), + this.i18nService.t('yes'), this.i18nService.t('no'), 'warning'); + + if (confirm) { + this.startToTray = false; + this.enableCloseToTray = false; + } else { + this.enableTray = true; + } + + return; + } + await this.storageService.save(ElectronConstants.enableTrayKey, this.enableTray); this.callAnalytics('Tray', this.enableTray); this.messagingService.send(this.enableTray ? 'showTray' : 'removeTray'); } async saveStartToTray() { + if (this.requireEnableTray) { + this.enableTray = true; + } + await this.storageService.save(ElectronConstants.enableStartToTrayKey, this.startToTray); this.callAnalytics('StartToTray', this.startToTray); } diff --git a/src/locales/en/messages.json b/src/locales/en/messages.json index 1710af535d..ce9692fa19 100644 --- a/src/locales/en/messages.json +++ b/src/locales/en/messages.json @@ -900,6 +900,12 @@ "alwaysShowDockDesc": { "message": "Show the Bitwarden icon in the Dock even when minimized to the menu bar." }, + "confirmTrayTitle": { + "message": "Confirm disable tray" + }, + "confirmTrayDesc": { + "message": "Disabling this setting will also disable all other tray related settings." + }, "language": { "message": "Language" },