1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-17 00:33:44 +00:00

simplify and enspeeden state resolution for blockedInteractionsUris

This commit is contained in:
Jonathan Prusik
2024-12-23 14:32:11 -05:00
parent a77d48ddba
commit b962373f71

View File

@@ -1,6 +1,6 @@
// FIXME: Update this file to be type safe and remove this and next line // FIXME: Update this file to be type safe and remove this and next line
// @ts-strict-ignore // @ts-strict-ignore
import { combineLatest, map, Observable } from "rxjs"; import { map, Observable, switchMap, of } from "rxjs";
import { FeatureFlag } from "@bitwarden/common/enums/feature-flag.enum"; import { FeatureFlag } from "@bitwarden/common/enums/feature-flag.enum";
@@ -97,18 +97,9 @@ export class DefaultDomainSettingsService implements DomainSettingsService {
// Needs to be global to prevent pre-login injections // Needs to be global to prevent pre-login injections
this.blockedInteractionsUrisState = this.stateProvider.getGlobal(BLOCKED_INTERACTIONS_URIS); this.blockedInteractionsUrisState = this.stateProvider.getGlobal(BLOCKED_INTERACTIONS_URIS);
this.blockedInteractionsUris$ = combineLatest([ this.blockedInteractionsUris$ = this.configService
this.blockedInteractionsUrisState.state$, .getFeatureFlag$(FeatureFlag.BlockBrowserInjectionsByDomain)
this.configService?.getFeatureFlag$(FeatureFlag.BlockBrowserInjectionsByDomain), .pipe(switchMap((enabled) => (enabled ? this.blockedInteractionsUrisState.state$ : of({}))));
]).pipe(
map(([blockedUris, blockBrowserInjectionsByDomainEnabled]) => {
if (!blockBrowserInjectionsByDomainEnabled) {
return null;
}
return blockedUris ?? null;
}),
);
this.equivalentDomainsState = this.stateProvider.getActive(EQUIVALENT_DOMAINS); this.equivalentDomainsState = this.stateProvider.getActive(EQUIVALENT_DOMAINS);
this.equivalentDomains$ = this.equivalentDomainsState.state$.pipe(map((x) => x ?? null)); this.equivalentDomains$ = this.equivalentDomainsState.state$.pipe(map((x) => x ?? null));