diff --git a/src/app/accounts/settings.component.html b/src/app/accounts/settings.component.html index 058630a8da..3399272b19 100644 --- a/src/app/accounts/settings.component.html +++ b/src/app/accounts/settings.component.html @@ -9,7 +9,8 @@
- {{'lockOptionsDesc' | i18n}} @@ -25,7 +26,7 @@
@@ -33,9 +34,9 @@
-
diff --git a/src/app/accounts/settings.component.ts b/src/app/accounts/settings.component.ts index a11e2bbeba..1c80495876 100644 --- a/src/app/accounts/settings.component.ts +++ b/src/app/accounts/settings.component.ts @@ -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(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}` }); } } diff --git a/src/app/services/services.module.ts b/src/app/services/services.module.ts index b24860f91f..723f3f21b2 100644 --- a/src/app/services/services.module.ts +++ b/src/app/services/services.module.ts @@ -33,6 +33,7 @@ import { LockService, PasswordGenerationService, SettingsService, + StateService, SyncService, TokenService, TotpService, @@ -55,6 +56,7 @@ import { PasswordGenerationService as PasswordGenerationServiceAbstraction, PlatformUtilsService as PlatformUtilsServiceAbstraction, SettingsService as SettingsServiceAbstraction, + StateService as StateServiceAbstraction, StorageService as StorageServiceAbstraction, SyncService as SyncServiceAbstraction, TokenService as TokenServiceAbstraction, @@ -67,6 +69,7 @@ webFrame.registerURLSchemeAsPrivileged('file'); const i18nService = new I18nService(window.navigator.language, './locales'); const utilsService = new UtilsService(); +const stateService = new StateService(); const platformUtilsService = new DesktopPlatformUtilsService(i18nService); const broadcasterService = new BroadcasterService(); const messagingService = new DesktopRendererMessagingService(broadcasterService); @@ -111,6 +114,8 @@ function initFactory(i18n: I18nService, platformUtils: DesktopPlatformUtilsServi const htmlEl = window.document.documentElement; htmlEl.classList.add('os_' + platformUtils.getDeviceString()); htmlEl.classList.add('locale_' + i18n.translationLocale); + stateService.save(ConstantsService.disableFaviconKey, + await storageService.get(ConstantsService.disableFaviconKey)); }; } @@ -142,6 +147,7 @@ function initFactory(i18n: I18nService, platformUtils: DesktopPlatformUtilsServi { provide: SettingsServiceAbstraction, useValue: settingsService }, { provide: LockServiceAbstraction, useValue: lockService }, { provide: StorageServiceAbstraction, useValue: storageService }, + { provide: StateServiceAbstraction, useValue: stateService }, { provide: APP_INITIALIZER, useFactory: initFactory, diff --git a/src/app/vault/ciphers.component.ts b/src/app/vault/ciphers.component.ts index 8909c13ae5..3bf2494713 100644 --- a/src/app/vault/ciphers.component.ts +++ b/src/app/vault/ciphers.component.ts @@ -26,7 +26,7 @@ export class CiphersComponent { searchPlaceholder: string = null; private filter: (cipher: CipherView) => boolean = null; - constructor(private cipherService: CipherService) {} + constructor(private cipherService: CipherService) { } async load(filter: (cipher: CipherView) => boolean = null) { this.filter = filter; @@ -42,6 +42,8 @@ export class CiphersComponent { } async refresh() { + this.loaded = false; + this.ciphers = []; await this.load(this.filter); } diff --git a/src/app/vault/icon.component.ts b/src/app/vault/icon.component.ts index f565cc2790..c9e555e4f7 100644 --- a/src/app/vault/icon.component.ts +++ b/src/app/vault/icon.component.ts @@ -9,6 +9,9 @@ import { import { CipherType } from 'jslib/enums/cipherType'; import { EnvironmentService } from 'jslib/abstractions/environment.service'; +import { StateService } from 'jslib/abstractions/state.service'; + +import { ConstantsService } from 'jslib/services/constants.service'; @Component({ selector: 'app-vault-icon', @@ -23,9 +26,7 @@ export class IconComponent implements OnChanges { private iconsUrl: string; - constructor(private environmentService: EnvironmentService) { - this.imageEnabled = true; // TODO - + constructor(private environmentService: EnvironmentService, private stateService: StateService) { this.iconsUrl = environmentService.iconsUrl; if (!this.iconsUrl) { if (environmentService.baseUrl) { @@ -36,7 +37,9 @@ export class IconComponent implements OnChanges { } } - ngOnChanges() { + async ngOnChanges() { + this.imageEnabled = !(await this.stateService.get(ConstantsService.disableFaviconKey)); + switch (this.cipher.type) { case CipherType.Login: this.icon = 'fa-globe'; diff --git a/src/app/vault/vault.component.ts b/src/app/vault/vault.component.ts index d757e27b5f..6c6e54796d 100644 --- a/src/app/vault/vault.component.ts +++ b/src/app/vault/vault.component.ts @@ -129,6 +129,9 @@ export class VaultComponent implements OnInit, OnDestroy { await this.load(); } break; + case 'refreshCiphers': + this.ciphersComponent.refresh(); + break; default: detectChanges = false; break;