mirror of
https://github.com/bitwarden/browser
synced 2025-12-06 00:13:28 +00:00
[PM-17465] refactor PolicyService.getAll$ to make userId not optional (#13031)
* refactor PolicyService.getAll$ to make userId not optional * add fix to browser * fix test to read from mock singleUserState * remove nested pipes, cleanup
This commit is contained in:
@@ -4,11 +4,13 @@ import { CommonModule } from "@angular/common";
|
||||
import { Component, Input, OnInit } from "@angular/core";
|
||||
import { takeUntilDestroyed } from "@angular/core/rxjs-interop";
|
||||
import { FormBuilder, ReactiveFormsModule } from "@angular/forms";
|
||||
import { firstValueFrom, map } from "rxjs";
|
||||
import { firstValueFrom, map, switchMap } from "rxjs";
|
||||
|
||||
import { JslibModule } from "@bitwarden/angular/jslib.module";
|
||||
import { PolicyService } from "@bitwarden/common/admin-console/abstractions/policy/policy.service.abstraction";
|
||||
import { PolicyType } from "@bitwarden/common/admin-console/enums";
|
||||
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
|
||||
import { getUserId } from "@bitwarden/common/auth/services/account.service";
|
||||
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
||||
import { SendView } from "@bitwarden/common/tools/send/models/view/send.view";
|
||||
import { SendApiService } from "@bitwarden/common/tools/send/services/send-api.service.abstraction";
|
||||
@@ -89,11 +91,14 @@ export class SendOptionsComponent implements OnInit {
|
||||
private i18nService: I18nService,
|
||||
private toastService: ToastService,
|
||||
private generatorService: CredentialGeneratorService,
|
||||
private accountService: AccountService,
|
||||
) {
|
||||
this.sendFormContainer.registerChildForm("sendOptionsForm", this.sendOptionsForm);
|
||||
this.policyService
|
||||
.getAll$(PolicyType.SendOptions)
|
||||
|
||||
this.accountService.activeAccount$
|
||||
.pipe(
|
||||
getUserId,
|
||||
switchMap((userId) => this.policyService.getAll$(PolicyType.SendOptions, userId)),
|
||||
map((policies) => policies?.some((p) => p.data.disableHideEmail)),
|
||||
takeUntilDestroyed(),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user