mirror of
https://github.com/bitwarden/browser.git
synced 2024-12-22 16:29:09 +01:00
default subaddress email to active account email (#11755)
This commit is contained in:
parent
3879f4bd85
commit
71db154856
@ -1,6 +1,6 @@
|
|||||||
import { Component, EventEmitter, Input, OnDestroy, OnInit, Output } from "@angular/core";
|
import { Component, EventEmitter, Input, OnDestroy, OnInit, Output } from "@angular/core";
|
||||||
import { FormBuilder } from "@angular/forms";
|
import { FormBuilder } from "@angular/forms";
|
||||||
import { BehaviorSubject, skip, Subject, takeUntil } from "rxjs";
|
import { BehaviorSubject, map, skip, Subject, takeUntil, withLatestFrom } from "rxjs";
|
||||||
|
|
||||||
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
|
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
|
||||||
import { UserId } from "@bitwarden/common/types/guid";
|
import { UserId } from "@bitwarden/common/types/guid";
|
||||||
@ -53,9 +53,23 @@ export class SubaddressSettingsComponent implements OnInit, OnDestroy {
|
|||||||
const singleUserId$ = this.singleUserId$();
|
const singleUserId$ = this.singleUserId$();
|
||||||
const settings = await this.generatorService.settings(Generators.subaddress, { singleUserId$ });
|
const settings = await this.generatorService.settings(Generators.subaddress, { singleUserId$ });
|
||||||
|
|
||||||
settings.pipe(takeUntil(this.destroyed$)).subscribe((s) => {
|
settings
|
||||||
this.settings.patchValue(s, { emitEvent: false });
|
.pipe(
|
||||||
});
|
withLatestFrom(this.accountService.activeAccount$),
|
||||||
|
map(([settings, activeAccount]) => {
|
||||||
|
// if the subaddress isn't specified, copy it from
|
||||||
|
// the user's settings
|
||||||
|
if ((settings.subaddressEmail ?? "").length < 1) {
|
||||||
|
settings.subaddressEmail = activeAccount.email;
|
||||||
|
}
|
||||||
|
|
||||||
|
return settings;
|
||||||
|
}),
|
||||||
|
takeUntil(this.destroyed$),
|
||||||
|
)
|
||||||
|
.subscribe((s) => {
|
||||||
|
this.settings.patchValue(s, { emitEvent: false });
|
||||||
|
});
|
||||||
|
|
||||||
// the first emission is the current value; subsequent emissions are updates
|
// the first emission is the current value; subsequent emissions are updates
|
||||||
settings.pipe(skip(1), takeUntil(this.destroyed$)).subscribe(this.onUpdated);
|
settings.pipe(skip(1), takeUntil(this.destroyed$)).subscribe(this.onUpdated);
|
||||||
|
Loading…
Reference in New Issue
Block a user