From c5edb3e04edfe8dfb01fe0e2be1bcfce83daf6ee Mon Sep 17 00:00:00 2001 From: Hinton Date: Mon, 14 Dec 2020 22:45:36 +0100 Subject: [PATCH 1/4] Fix autostart in snap --- package.json | 1 + src/main/messaging.main.ts | 14 +++++++------- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index 64b8f16281..a1c8228c2c 100644 --- a/package.json +++ b/package.json @@ -221,6 +221,7 @@ "artifactName": "${productName}-${version}-${arch}.${ext}" }, "snap": { + "autoStart": true, "confinement": "strict", "plugs": [ "default", diff --git a/src/main/messaging.main.ts b/src/main/messaging.main.ts index 02981422f4..a6a6079331 100644 --- a/src/main/messaging.main.ts +++ b/src/main/messaging.main.ts @@ -102,13 +102,13 @@ export class MessagingMain { private addOpenAtLogin() { if (process.platform === 'linux') { const data = `[Desktop Entry] - Type=Application - Version=${app.getVersion()} - Name=Bitwarden - Comment=Bitwarden startup script - Exec=${app.getPath('exe')} - StartupNotify=false - Terminal=false`; +Type=Application +Version=${app.getVersion()} +Name=Bitwarden +Comment=Bitwarden startup script +Exec=${app.getPath('exe')} +StartupNotify=false +Terminal=false`; const dir = path.dirname(this.linuxStartupFile()); if (!fs.existsSync(dir)) { From 41e72b22b8340ccc6a54f75ecd2a5f9872e7adb5 Mon Sep 17 00:00:00 2001 From: Hinton Date: Tue, 15 Dec 2020 20:37:30 +0100 Subject: [PATCH 2/4] Prevent disabling enableTray on linux when using other tray settings --- src/app/accounts/settings.component.ts | 27 ++++++++++++++++++++++++++ src/locales/en/messages.json | 6 ++++++ 2 files changed, 33 insertions(+) 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" }, From 22ddd8db60b4073f9e9165db68ac45a468d67849 Mon Sep 17 00:00:00 2001 From: Hinton Date: Wed, 16 Dec 2020 09:38:28 +0100 Subject: [PATCH 3/4] Ensure settings are saved --- src/app/accounts/settings.component.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/app/accounts/settings.component.ts b/src/app/accounts/settings.component.ts index eb0b8b259d..2abab4b10d 100644 --- a/src/app/accounts/settings.component.ts +++ b/src/app/accounts/settings.component.ts @@ -275,6 +275,7 @@ export class SettingsComponent implements OnInit { async saveCloseToTray() { if (this.requireEnableTray) { this.enableTray = true; + await this.storageService.save(ElectronConstants.enableTrayKey, this.enableTray); } await this.storageService.save(ElectronConstants.enableCloseToTrayKey, this.enableCloseToTray); @@ -289,7 +290,9 @@ export class SettingsComponent implements OnInit { if (confirm) { this.startToTray = false; + await this.storageService.save(ElectronConstants.enableStartToTrayKey, this.startToTray); this.enableCloseToTray = false; + await this.storageService.save(ElectronConstants.enableCloseToTrayKey, this.enableCloseToTray); } else { this.enableTray = true; } @@ -305,6 +308,7 @@ export class SettingsComponent implements OnInit { async saveStartToTray() { if (this.requireEnableTray) { this.enableTray = true; + await this.storageService.save(ElectronConstants.enableTrayKey, this.enableTray); } await this.storageService.save(ElectronConstants.enableStartToTrayKey, this.startToTray); From 5d1057b3fa4d139c8b95afc897bb27a9fbf9ffed Mon Sep 17 00:00:00 2001 From: Hinton Date: Wed, 16 Dec 2020 09:41:00 +0100 Subject: [PATCH 4/4] Update jslib --- jslib | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jslib b/jslib index 2c414ce27a..d7b5f0a26b 160000 --- a/jslib +++ b/jslib @@ -1 +1 @@ -Subproject commit 2c414ce27a5c14f6cd7f86cfd07096a192d058ca +Subproject commit d7b5f0a26b15472b37aef2248dea51a2aa6d4916