1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-16 00:03:56 +00:00

[EC-381] Transition settings service into providing observables (#3253)

* [EC-381] Deleted unused method clearCache from Settings Service

* [EC-381] Marked settings methods as obsolete on State service

* [EC-381] Using observables on settings service

* [EC-381] Added unit tests for Settings service

* [EC-381] Checking userId on clear

* [EC-381] Updated references to StateService activeAccountUnlocked$

* [EC-381] Updated getEquivalentDomains to return observable

* [EC-381] Updated settings service to user concatMap on activeAccountUnlocked$

* [EC-381] Renamed getEquivalentDomains to equivalentDomains

* [EC-381] Completing Behaviors on settings.service tests

* [EC-381] Removed unused settingsPrefix from settings service

* [EC-381] Removed equivalentDomains from settings service and added type AccountSettingsSettings

* [EC-381] Updated settings service settings$ to not be nullable

* [EC-381] Settings default to {}
This commit is contained in:
Rui Tomé
2022-08-30 15:19:09 +01:00
committed by GitHub
parent 88a6541bd8
commit 595412c5fe
8 changed files with 148 additions and 63 deletions

View File

@@ -1,3 +1,5 @@
import { firstValueFrom } from "rxjs";
import { ApiService } from "../abstractions/api.service";
import { CipherService as CipherServiceAbstraction } from "../abstractions/cipher.service";
import { CryptoService } from "../abstractions/crypto.service";
@@ -13,6 +15,7 @@ import { UriMatchType } from "../enums/uriMatchType";
import { sequentialize } from "../misc/sequentialize";
import { Utils } from "../misc/utils";
import { CipherData } from "../models/data/cipherData";
import { AccountSettingsSettings } from "../models/domain/account";
import { Attachment } from "../models/domain/attachment";
import { Card } from "../models/domain/card";
import { Cipher } from "../models/domain/cipher";
@@ -387,20 +390,22 @@ export class CipherService implements CipherServiceAbstraction {
const eqDomainsPromise =
domain == null
? Promise.resolve([])
: this.settingsService.getEquivalentDomains().then((eqDomains: any[][]) => {
let matches: any[] = [];
eqDomains.forEach((eqDomain) => {
if (eqDomain.length && eqDomain.indexOf(domain) >= 0) {
matches = matches.concat(eqDomain);
: firstValueFrom(this.settingsService.settings$).then(
(settings: AccountSettingsSettings) => {
let matches: any[] = [];
settings.equivalentDomains.forEach((eqDomain: any) => {
if (eqDomain.length && eqDomain.indexOf(domain) >= 0) {
matches = matches.concat(eqDomain);
}
});
if (!matches.length) {
matches.push(domain);
}
});
if (!matches.length) {
matches.push(domain);
return matches;
}
return matches;
});
);
const result = await Promise.all([eqDomainsPromise, this.getAllDecrypted()]);
const matchingDomains = result[0];