Prevent disabling enableTray on linux when using other tray settings

This commit is contained in:
Hinton 2020-12-15 20:37:30 +01:00
parent c5edb3e04e
commit 41e72b22b8
2 changed files with 33 additions and 0 deletions

View File

@ -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);
}

View File

@ -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"
},