mirror of
https://github.com/bitwarden/browser
synced 2026-02-08 20:50:28 +00:00
eliminate repeat algorithm emissions
This commit is contained in:
@@ -171,13 +171,13 @@ export class CredentialGeneratorComponent implements OnInit, OnChanges, OnDestro
|
||||
// construct options for username and email algorithms; replace forwarder
|
||||
// entry with a virtual entry for drill-down
|
||||
const usernames = algorithms.filter((a) => !isForwarderExtensionId(a.id));
|
||||
usernames.sort((un) => un.weight);
|
||||
usernames.sort((username) => username.weight);
|
||||
const usernameOptions = this.toOptions(usernames);
|
||||
usernameOptions.push({ value: FORWARDER, label: this.i18nService.t("forwardedEmail") });
|
||||
|
||||
// construct options for forwarder algorithms; they get their own selection box
|
||||
const forwarders = algorithms.filter((a) => isForwarderExtensionId(a.id));
|
||||
forwarders.sort((fwd) => fwd.weight);
|
||||
forwarders.sort((forwarder) => forwarder.weight);
|
||||
const forwarderOptions = this.toOptions(forwarders);
|
||||
forwarderOptions.unshift({ value: NONE_SELECTED, label: this.i18nService.t("select") });
|
||||
|
||||
@@ -475,14 +475,10 @@ export class CredentialGeneratorComponent implements OnInit, OnChanges, OnDestro
|
||||
this.username.setValue(username.selection, { emitEvent: false });
|
||||
this.forwarder.setValue(forwarder.selection, { emitEvent: false });
|
||||
|
||||
// update subjects within the angular zone so that the
|
||||
// template bindings refresh immediately
|
||||
this.zone.run(() => {
|
||||
// update cascade visibility
|
||||
activeRoot$.next(root.active);
|
||||
activeIdentifier$.next(username.active);
|
||||
activeForwarder$.next(forwarder.active);
|
||||
});
|
||||
// update cascade visibility
|
||||
activeRoot$.next(root.active);
|
||||
activeIdentifier$.next(username.active);
|
||||
activeForwarder$.next(forwarder.active);
|
||||
});
|
||||
|
||||
// automatically regenerate when the algorithm switches if the algorithm
|
||||
|
||||
@@ -14,7 +14,7 @@ import { BoundDependency } from "@bitwarden/common/tools/dependencies";
|
||||
import { ExtensionSite } from "@bitwarden/common/tools/extension";
|
||||
import { SemanticLogger } from "@bitwarden/common/tools/log";
|
||||
import { SystemServiceProvider } from "@bitwarden/common/tools/providers";
|
||||
import { anyComplete, pin } from "@bitwarden/common/tools/rx";
|
||||
import { anyComplete, memoizedMap, pin } from "@bitwarden/common/tools/rx";
|
||||
import { UserStateSubject } from "@bitwarden/common/tools/state/user-state-subject";
|
||||
import { UserStateSubjectDependencyProvider } from "@bitwarden/common/tools/state/user-state-subject-dependency-provider";
|
||||
|
||||
@@ -149,7 +149,8 @@ export class GeneratorMetadataProvider {
|
||||
.policiesByType$(PolicyType.PasswordGenerator, id)
|
||||
.pipe(
|
||||
map((p) => availableAlgorithms(p).filter((a) => this._metadata.has(a))),
|
||||
map((p) => new Set(p)),
|
||||
memoizedMap((p) => new Set(p), { key: (p) => JSON.stringify(p) }),
|
||||
distinctUntilChanged(),
|
||||
// complete policy emissions otherwise `switchMap` holds `available$` open indefinitely
|
||||
takeUntil(anyComplete(id$)),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user