1
0
mirror of https://github.com/bitwarden/desktop.git synced 2024-11-28 12:35:40 +01:00

Add support for "openAtLogin"

This commit is contained in:
Hinton 2020-11-25 20:43:29 +01:00
parent f926f80d8c
commit f512df309d
4 changed files with 25 additions and 13 deletions

View File

@ -130,13 +130,13 @@
</div>
<div class="form-group">
<div class="checkbox">
<label for="startOnLogin">
<input id="startOnLogin" type="checkbox" name="StartOnLogin" [(ngModel)]="startOnLogin"
(change)="saveStartOnLogin()">
{{'startOnLogin' | i18n}}
<label for="openAtLogin">
<input id="openAtLogin" type="checkbox" name="OpenAtLogin" [(ngModel)]="openAtLogin"
(change)="saveOpenAtLogin()">
{{'openAtLogin' | i18n}}
</label>
</div>
<small class="help-block">{{'startOnLoginDesc' | i18n}}</small>
<small class="help-block">{{'openAtLoginDesc' | i18n}}</small>
</div>
<div class="form-group" *ngIf="showAlwaysShowDock">
<div class="checkbox">

View File

@ -51,7 +51,7 @@ export class SettingsComponent implements OnInit {
biometricText: string;
alwaysShowDock: boolean;
showAlwaysShowDock: boolean = false;
startOnLogin: boolean;
openAtLogin: boolean;
enableTrayText: string;
enableTrayDescText: string;
@ -157,6 +157,7 @@ export class SettingsComponent implements OnInit {
this.biometricText = await this.storageService.get<string>(ConstantsService.biometricText);
this.alwaysShowDock = await this.storageService.get<boolean>(ElectronConstants.alwaysShowDock);
this.showAlwaysShowDock = this.platformUtilsService.getDevice() === DeviceType.MacOsDesktop;
this.openAtLogin = await this.storageService.get<boolean>(ElectronConstants.openAtLogin);
}
async saveVaultTimeoutOptions() {
@ -307,8 +308,9 @@ export class SettingsComponent implements OnInit {
await this.storageService.save(ElectronConstants.alwaysShowDock, this.alwaysShowDock);
}
async saveStartOnLogin() {
this.messagingService.send(this.startOnLogin ? 'addOpenAtLogin' : 'removeOpenAtLogin');
async saveOpenAtLogin() {
this.storageService.save(ElectronConstants.openAtLogin, this.openAtLogin);
this.messagingService.send(this.openAtLogin ? 'addOpenAtLogin' : 'removeOpenAtLogin');
}
private callAnalytics(name: string, enabled: boolean) {

View File

@ -888,10 +888,10 @@
"startToMenuBarDesc": {
"message": "When the application is first started, only show an icon in the menu bar."
},
"startOnLogin": {
"openAtLogin": {
"message": "Start automatically on login"
},
"startOnLoginDesc": {
"openAtLoginDesc": {
"message": "Start the Bitwarden Desktop application automatically on login."
},
"alwaysShowDock": {

View File

@ -1,4 +1,4 @@
import { ipcMain } from 'electron';
import { app, ipcMain } from 'electron';
import { Main } from '../main';
@ -15,6 +15,10 @@ export class MessagingMain {
init() {
this.scheduleNextSync();
if (process.platform !== 'linux') {
const loginSettings = app.getLoginItemSettings();
this.storageService.save(ElectronConstants.openAtLogin, loginSettings.openAtLogin);
}
ipcMain.on('messagingService', async (event: any, message: any) => this.onMessage(message));
}
@ -44,9 +48,15 @@ export class MessagingMain {
case 'hideToTray':
this.main.trayMain.hideToTray();
break;
case 'addStartOnLogin':
case 'addOpenAtLogin':
if (process.platform !== 'linux') {
app.setLoginItemSettings({openAtLogin: true});
}
break;
case 'removeStartOnLogin':
case 'removeOpenAtLogin':
if (process.platform !== 'linux') {
app.setLoginItemSettings({openAtLogin: false});
}
break;
default:
break;