1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-09-27 04:03:00 +02:00

Use placeholders, minor code and style fixes

This commit is contained in:
Thomas Rittson 2021-01-14 18:04:30 +10:00
parent 078111a4fc
commit caa4d5990d
2 changed files with 15 additions and 9 deletions

View File

@ -1445,6 +1445,12 @@
"message": "Bitwarden will not ask to save login details for these domains." "message": "Bitwarden will not ask to save login details for these domains."
}, },
"excludedDomainsInvalidDomain": { "excludedDomainsInvalidDomain": {
"message": " is not a valid domain" "message": "$DOMAIN$ is not a valid domain",
"placeholders": {
"domain": {
"content": "$1",
"example": "googlecom"
}
}
} }
} }

View File

@ -16,8 +16,8 @@ import { BrowserApi } from '../../browser/browserApi';
import { Utils } from 'jslib/misc/utils'; import { Utils } from 'jslib/misc/utils';
interface ExcludedDomain { interface ExcludedDomain {
uri: string, uri: string;
showCurrentUris: boolean showCurrentUris: boolean;
} }
const BroadcasterSubscriptionId = 'excludedDomains'; const BroadcasterSubscriptionId = 'excludedDomains';
@ -41,11 +41,11 @@ export class ExcludedDomainsComponent implements OnInit, OnDestroy {
const savedDomains = await this.storageService.get<any>(ConstantsService.neverDomainsKey); const savedDomains = await this.storageService.get<any>(ConstantsService.neverDomainsKey);
if (savedDomains) { if (savedDomains) {
for (const uri of Object.keys(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.broadcasterService.subscribe(BroadcasterSubscriptionId, (message: any) => {
this.ngZone.run(async () => { this.ngZone.run(async () => {
@ -55,7 +55,7 @@ export class ExcludedDomainsComponent implements OnInit, OnDestroy {
if (this.loadCurrentUrisTimeout != null) { if (this.loadCurrentUrisTimeout != null) {
window.clearTimeout(this.loadCurrentUrisTimeout); window.clearTimeout(this.loadCurrentUrisTimeout);
} }
this.loadCurrentUrisTimeout = window.setTimeout(() => this.loadCurrentUris(), 500); this.loadCurrentUrisTimeout = window.setTimeout(async () => await this.loadCurrentUris(), 500);
break; break;
default: default:
break; break;
@ -69,7 +69,7 @@ export class ExcludedDomainsComponent implements OnInit, OnDestroy {
} }
async addUri() { async addUri() {
this.excludedDomains.push({ uri: '', showCurrentUris: false }) this.excludedDomains.push({ uri: '', showCurrentUris: false });
} }
async removeUri(i: number) { async removeUri(i: number) {
@ -83,10 +83,10 @@ export class ExcludedDomainsComponent implements OnInit, OnDestroy {
const validDomain = Utils.getHostname(domain.uri); const validDomain = Utils.getHostname(domain.uri);
if (!validDomain) { if (!validDomain) {
this.platformUtilsService.showToast('error', null, this.platformUtilsService.showToast('error', null,
'\'' + domain.uri + '\'' + this.i18nService.t('excludedDomainsInvalidDomain')); this.i18nService.t('excludedDomainsInvalidDomain', domain.uri));
return; return;
} }
savedDomains[validDomain] = null savedDomains[validDomain] = null;
} }
} }
await this.storageService.save(ConstantsService.neverDomainsKey, savedDomains); await this.storageService.save(ConstantsService.neverDomainsKey, savedDomains);