mirror of
https://github.com/bitwarden/browser.git
synced 2024-10-22 07:50:04 +02:00
fix repeating algorithm updates
This commit is contained in:
parent
b2f2da74ef
commit
883aff47a3
@ -146,7 +146,7 @@ export class CredentialGeneratorComponent implements OnInit, OnDestroy {
|
|||||||
|
|
||||||
this.algorithm$
|
this.algorithm$
|
||||||
.pipe(
|
.pipe(
|
||||||
map((a) => a.category),
|
map((a) => a?.category),
|
||||||
distinctUntilChanged(),
|
distinctUntilChanged(),
|
||||||
takeUntil(this.destroyed),
|
takeUntil(this.destroyed),
|
||||||
)
|
)
|
||||||
@ -161,6 +161,7 @@ export class CredentialGeneratorComponent implements OnInit, OnDestroy {
|
|||||||
// wire up the generator
|
// wire up the generator
|
||||||
this.algorithm$
|
this.algorithm$
|
||||||
.pipe(
|
.pipe(
|
||||||
|
filter((algorithm) => !!algorithm),
|
||||||
switchMap((algorithm) => this.typeToGenerator$(algorithm.id)),
|
switchMap((algorithm) => this.typeToGenerator$(algorithm.id)),
|
||||||
takeUntil(this.destroyed),
|
takeUntil(this.destroyed),
|
||||||
)
|
)
|
||||||
@ -219,14 +220,19 @@ export class CredentialGeneratorComponent implements OnInit, OnDestroy {
|
|||||||
|
|
||||||
// update forwarder cascade visibility
|
// update forwarder cascade visibility
|
||||||
combineLatest([activeRoot$, activeIdentifier$, activeForwarder$])
|
combineLatest([activeRoot$, activeIdentifier$, activeForwarder$])
|
||||||
.pipe(takeUntil(this.destroyed))
|
.pipe(
|
||||||
.subscribe(([root, username, forwarder]) => {
|
map(([root, username, forwarder]) => {
|
||||||
const showForwarder = !root.algorithm && !username.algorithm;
|
const showForwarder = !root.algorithm && !username.algorithm;
|
||||||
const forwarderId =
|
const forwarderId =
|
||||||
showForwarder && isForwarderIntegration(forwarder.algorithm)
|
showForwarder && isForwarderIntegration(forwarder.algorithm)
|
||||||
? forwarder.algorithm.forwarder
|
? forwarder.algorithm.forwarder
|
||||||
: null;
|
: null;
|
||||||
|
return [showForwarder, forwarderId] as const;
|
||||||
|
}),
|
||||||
|
distinctUntilChanged((prev, next) => prev[0] === next[0] && prev[1] === next[1]),
|
||||||
|
takeUntil(this.destroyed),
|
||||||
|
)
|
||||||
|
.subscribe(([showForwarder, forwarderId]) => {
|
||||||
// update subjects within the angular zone so that the
|
// update subjects within the angular zone so that the
|
||||||
// template bindings refresh immediately
|
// template bindings refresh immediately
|
||||||
this.zone.run(() => {
|
this.zone.run(() => {
|
||||||
@ -246,6 +252,7 @@ export class CredentialGeneratorComponent implements OnInit, OnDestroy {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
|
distinctUntilChanged((prev, next) => isSameAlgorithm(prev?.id, next?.id)),
|
||||||
takeUntil(this.destroyed),
|
takeUntil(this.destroyed),
|
||||||
)
|
)
|
||||||
.subscribe((algorithm) => {
|
.subscribe((algorithm) => {
|
||||||
@ -261,7 +268,6 @@ export class CredentialGeneratorComponent implements OnInit, OnDestroy {
|
|||||||
this.algorithm$
|
this.algorithm$
|
||||||
.pipe(
|
.pipe(
|
||||||
filter((algorithm) => !!algorithm),
|
filter((algorithm) => !!algorithm),
|
||||||
distinctUntilChanged((prev, next) => isSameAlgorithm(prev.id, next.id)),
|
|
||||||
withLatestFrom(preferences),
|
withLatestFrom(preferences),
|
||||||
takeUntil(this.destroyed),
|
takeUntil(this.destroyed),
|
||||||
)
|
)
|
||||||
@ -346,20 +352,15 @@ export class CredentialGeneratorComponent implements OnInit, OnDestroy {
|
|||||||
|
|
||||||
// automatically regenerate when the algorithm switches if the algorithm
|
// automatically regenerate when the algorithm switches if the algorithm
|
||||||
// allows it; otherwise set a placeholder
|
// allows it; otherwise set a placeholder
|
||||||
this.algorithm$
|
this.algorithm$.pipe(takeUntil(this.destroyed)).subscribe((a) => {
|
||||||
.pipe(
|
this.zone.run(() => {
|
||||||
distinctUntilChanged((prev, next) => isSameAlgorithm(prev.id, next.id)),
|
if (!a || a.onlyOnRequest) {
|
||||||
takeUntil(this.destroyed),
|
this.value$.next("-");
|
||||||
)
|
} else {
|
||||||
.subscribe((a) => {
|
this.generate$.next();
|
||||||
this.zone.run(() => {
|
}
|
||||||
if (!a || a.onlyOnRequest) {
|
|
||||||
this.value$.next("-");
|
|
||||||
} else {
|
|
||||||
this.generate$.next();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private typeToGenerator$(type: CredentialAlgorithm) {
|
private typeToGenerator$(type: CredentialAlgorithm) {
|
||||||
|
Loading…
Reference in New Issue
Block a user