From caa4d5990dd4e06fed3b5455c6dfdd56f3ec5717 Mon Sep 17 00:00:00 2001 From: Thomas Rittson Date: Thu, 14 Jan 2021 18:04:30 +1000 Subject: [PATCH] Use placeholders, minor code and style fixes --- src/_locales/en/messages.json | 8 +++++++- src/popup/settings/excluded-domains.component.ts | 16 ++++++++-------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/_locales/en/messages.json b/src/_locales/en/messages.json index ba36b04c3b..157148445c 100644 --- a/src/_locales/en/messages.json +++ b/src/_locales/en/messages.json @@ -1445,6 +1445,12 @@ "message": "Bitwarden will not ask to save login details for these domains." }, "excludedDomainsInvalidDomain": { - "message": " is not a valid domain" + "message": "$DOMAIN$ is not a valid domain", + "placeholders": { + "domain": { + "content": "$1", + "example": "googlecom" + } + } } } diff --git a/src/popup/settings/excluded-domains.component.ts b/src/popup/settings/excluded-domains.component.ts index b09d8570dd..57bfa0bb02 100644 --- a/src/popup/settings/excluded-domains.component.ts +++ b/src/popup/settings/excluded-domains.component.ts @@ -16,8 +16,8 @@ import { BrowserApi } from '../../browser/browserApi'; import { Utils } from 'jslib/misc/utils'; interface ExcludedDomain { - uri: string, - showCurrentUris: boolean + uri: string; + showCurrentUris: boolean; } const BroadcasterSubscriptionId = 'excludedDomains'; @@ -41,11 +41,11 @@ export class ExcludedDomainsComponent implements OnInit, OnDestroy { const savedDomains = await this.storageService.get(ConstantsService.neverDomainsKey); if (savedDomains) { for (const uri of Object.keys(savedDomains)) { - this.excludedDomains.push({ uri: uri, showCurrentUris: false }) + this.excludedDomains.push({ uri: uri, showCurrentUris: false }); } } - this.loadCurrentUris(); + await this.loadCurrentUris(); this.broadcasterService.subscribe(BroadcasterSubscriptionId, (message: any) => { this.ngZone.run(async () => { @@ -55,7 +55,7 @@ export class ExcludedDomainsComponent implements OnInit, OnDestroy { if (this.loadCurrentUrisTimeout != null) { window.clearTimeout(this.loadCurrentUrisTimeout); } - this.loadCurrentUrisTimeout = window.setTimeout(() => this.loadCurrentUris(), 500); + this.loadCurrentUrisTimeout = window.setTimeout(async () => await this.loadCurrentUris(), 500); break; default: break; @@ -69,7 +69,7 @@ export class ExcludedDomainsComponent implements OnInit, OnDestroy { } async addUri() { - this.excludedDomains.push({ uri: '', showCurrentUris: false }) + this.excludedDomains.push({ uri: '', showCurrentUris: false }); } async removeUri(i: number) { @@ -83,10 +83,10 @@ export class ExcludedDomainsComponent implements OnInit, OnDestroy { const validDomain = Utils.getHostname(domain.uri); if (!validDomain) { this.platformUtilsService.showToast('error', null, - '\'' + domain.uri + '\'' + this.i18nService.t('excludedDomainsInvalidDomain')); + this.i18nService.t('excludedDomainsInvalidDomain', domain.uri)); return; } - savedDomains[validDomain] = null + savedDomains[validDomain] = null; } } await this.storageService.save(ConstantsService.neverDomainsKey, savedDomains);