initialize subscription after setting initial values (#9579)
This commit is contained in:
parent
a7912ad10c
commit
c1d3659a28
|
@ -10,6 +10,7 @@ import {
|
||||||
map,
|
map,
|
||||||
Observable,
|
Observable,
|
||||||
pairwise,
|
pairwise,
|
||||||
|
startWith,
|
||||||
Subject,
|
Subject,
|
||||||
switchMap,
|
switchMap,
|
||||||
takeUntil,
|
takeUntil,
|
||||||
|
@ -150,8 +151,25 @@ export class AccountSecurityComponent implements OnInit {
|
||||||
timeout = VaultTimeoutStringType.OnRestart;
|
timeout = VaultTimeoutStringType.OnRestart;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const initialValues = {
|
||||||
|
vaultTimeout: timeout,
|
||||||
|
vaultTimeoutAction: await firstValueFrom(
|
||||||
|
this.vaultTimeoutSettingsService.getVaultTimeoutActionByUserId$(activeAccount.id),
|
||||||
|
),
|
||||||
|
pin: await this.pinService.isPinSet(activeAccount.id),
|
||||||
|
biometric: await this.vaultTimeoutSettingsService.isBiometricLockSet(),
|
||||||
|
enableAutoBiometricsPrompt: await firstValueFrom(
|
||||||
|
this.biometricStateService.promptAutomatically$,
|
||||||
|
),
|
||||||
|
};
|
||||||
|
this.form.patchValue(initialValues, { emitEvent: false });
|
||||||
|
|
||||||
|
this.supportsBiometric = await this.platformUtilsService.supportsBiometric();
|
||||||
|
this.showChangeMasterPass = await this.userVerificationService.hasMasterPassword();
|
||||||
|
|
||||||
this.form.controls.vaultTimeout.valueChanges
|
this.form.controls.vaultTimeout.valueChanges
|
||||||
.pipe(
|
.pipe(
|
||||||
|
startWith(initialValues.vaultTimeout), // emit to init pairwise
|
||||||
pairwise(),
|
pairwise(),
|
||||||
concatMap(async ([previousValue, newValue]) => {
|
concatMap(async ([previousValue, newValue]) => {
|
||||||
await this.saveVaultTimeout(previousValue, newValue);
|
await this.saveVaultTimeout(previousValue, newValue);
|
||||||
|
@ -162,6 +180,7 @@ export class AccountSecurityComponent implements OnInit {
|
||||||
|
|
||||||
this.form.controls.vaultTimeoutAction.valueChanges
|
this.form.controls.vaultTimeoutAction.valueChanges
|
||||||
.pipe(
|
.pipe(
|
||||||
|
startWith(initialValues.vaultTimeoutAction), // emit to init pairwise
|
||||||
pairwise(),
|
pairwise(),
|
||||||
concatMap(async ([previousValue, newValue]) => {
|
concatMap(async ([previousValue, newValue]) => {
|
||||||
await this.saveVaultTimeoutAction(previousValue, newValue);
|
await this.saveVaultTimeoutAction(previousValue, newValue);
|
||||||
|
@ -170,24 +189,6 @@ export class AccountSecurityComponent implements OnInit {
|
||||||
)
|
)
|
||||||
.subscribe();
|
.subscribe();
|
||||||
|
|
||||||
const userId = (await firstValueFrom(this.accountService.activeAccount$))?.id;
|
|
||||||
|
|
||||||
const initialValues = {
|
|
||||||
vaultTimeout: timeout,
|
|
||||||
vaultTimeoutAction: await firstValueFrom(
|
|
||||||
this.vaultTimeoutSettingsService.getVaultTimeoutActionByUserId$(activeAccount.id),
|
|
||||||
),
|
|
||||||
pin: await this.pinService.isPinSet(userId),
|
|
||||||
biometric: await this.vaultTimeoutSettingsService.isBiometricLockSet(),
|
|
||||||
enableAutoBiometricsPrompt: await firstValueFrom(
|
|
||||||
this.biometricStateService.promptAutomatically$,
|
|
||||||
),
|
|
||||||
};
|
|
||||||
this.form.patchValue(initialValues); // Emit event to initialize `pairwise` operator
|
|
||||||
|
|
||||||
this.supportsBiometric = await this.platformUtilsService.supportsBiometric();
|
|
||||||
this.showChangeMasterPass = await this.userVerificationService.hasMasterPassword();
|
|
||||||
|
|
||||||
this.form.controls.pin.valueChanges
|
this.form.controls.pin.valueChanges
|
||||||
.pipe(
|
.pipe(
|
||||||
concatMap(async (value) => {
|
concatMap(async (value) => {
|
||||||
|
|
Loading…
Reference in New Issue