mirror of
https://github.com/bitwarden/browser
synced 2025-12-22 11:13:46 +00:00
apply settings with state service.
This commit is contained in:
@@ -9,7 +9,8 @@
|
||||
<div class="box-content box-content-padded">
|
||||
<div class="form-group">
|
||||
<label for="lockOption">{{'lockOptions' | i18n}}</label>
|
||||
<select id="lockOption" name="LockOption" [(ngModel)]="lockOption" (change)="save()">
|
||||
<select id="lockOption" name="LockOption" [(ngModel)]="lockOption"
|
||||
(change)="saveLockOption()">
|
||||
<option *ngFor="let o of lockOptions" [ngValue]="o.value">{{o.name}}</option>
|
||||
</select>
|
||||
<small class="help-block">{{'lockOptionsDesc' | i18n}}</small>
|
||||
@@ -25,7 +26,7 @@
|
||||
<div class="checkbox">
|
||||
<label for="disableGa">
|
||||
<input id="disableGa" type="checkbox" name="DisableAnalytics"
|
||||
[(ngModel)]="disableGa" (change)="save()">
|
||||
[(ngModel)]="disableGa" (change)="saveGa()">
|
||||
{{'disableGa' | i18n}}
|
||||
</label>
|
||||
</div>
|
||||
@@ -33,9 +34,9 @@
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="checkbox">
|
||||
<label for="disableFavicon">
|
||||
<input id="disableFavicon" type="checkbox" name="DisableFavicon"
|
||||
[(ngModel)]="disableFavicons" (change)="save()">
|
||||
<label for="disableFavicons">
|
||||
<input id="disableFavicons" type="checkbox" name="DisableFavicons"
|
||||
[(ngModel)]="disableFavicons" (change)="saveFavicons()">
|
||||
{{'disableFavicon' | i18n}}
|
||||
</label>
|
||||
</div>
|
||||
|
||||
@@ -10,7 +10,9 @@ import { Angulartics2 } from 'angulartics2';
|
||||
|
||||
import { I18nService } from 'jslib/abstractions/i18n.service';
|
||||
import { LockService } from 'jslib/abstractions/lock.service';
|
||||
import { MessagingService } from 'jslib/abstractions/messaging.service';
|
||||
import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service';
|
||||
import { StateService } from 'jslib/abstractions/state.service';
|
||||
import { StorageService } from 'jslib/abstractions/storage.service';
|
||||
|
||||
import { ConstantsService } from 'jslib/services/constants.service';
|
||||
@@ -27,7 +29,8 @@ export class SettingsComponent implements OnInit {
|
||||
|
||||
constructor(private analytics: Angulartics2, private toasterService: ToasterService,
|
||||
private i18nService: I18nService, private platformUtilsService: PlatformUtilsService,
|
||||
private storageService: StorageService, private lockService: LockService) {
|
||||
private storageService: StorageService, private lockService: LockService,
|
||||
private stateService: StateService, private messagingService: MessagingService) {
|
||||
this.lockOptions = [
|
||||
// { name: i18nService.t('immediately'), value: 0 },
|
||||
{ name: i18nService.t('oneMinute'), value: 1 },
|
||||
@@ -50,9 +53,29 @@ export class SettingsComponent implements OnInit {
|
||||
this.disableFavicons = await this.storageService.get<boolean>(ConstantsService.disableFaviconKey);
|
||||
}
|
||||
|
||||
async save() {
|
||||
async saveLockOption() {
|
||||
await this.lockService.setLockOption(this.lockOption != null ? this.lockOption : null);
|
||||
}
|
||||
|
||||
async saveGa() {
|
||||
if (this.disableGa) {
|
||||
this.callAnalytics('Analytics', !this.disableGa);
|
||||
}
|
||||
await this.storageService.save(ConstantsService.disableGaKey, this.disableGa);
|
||||
if (!this.disableGa) {
|
||||
this.callAnalytics('Analytics', !this.disableGa);
|
||||
}
|
||||
}
|
||||
|
||||
async saveFavicons() {
|
||||
await this.storageService.save(ConstantsService.disableFaviconKey, this.disableFavicons);
|
||||
await this.stateService.save(ConstantsService.disableFaviconKey, this.disableFavicons);
|
||||
this.messagingService.send('refreshCiphers');
|
||||
this.callAnalytics('Favicons', !this.disableGa);
|
||||
}
|
||||
|
||||
private callAnalytics(name: string, enabled: boolean) {
|
||||
const status = enabled ? 'Enabled' : 'Disabled';
|
||||
this.analytics.eventTrack.next({ action: `${status} ${name}` });
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user