mirror of
https://github.com/bitwarden/browser
synced 2026-02-09 05:00:10 +00:00
code cleanup
This commit is contained in:
@@ -23,7 +23,6 @@ import {
|
||||
ReplaySubject,
|
||||
Subject,
|
||||
takeUntil,
|
||||
tap,
|
||||
withLatestFrom,
|
||||
} from "rxjs";
|
||||
|
||||
@@ -234,9 +233,7 @@ export class CredentialGeneratorComponent implements OnInit, OnChanges, OnDestro
|
||||
// wire up the generator
|
||||
this.generatorService
|
||||
.generate$({
|
||||
on$: this.generate$.pipe(
|
||||
tap((g) => this.log.debug(g, "generate request issued by component")),
|
||||
),
|
||||
on$: this.generate$,
|
||||
account$: this.account$,
|
||||
})
|
||||
.pipe(
|
||||
|
||||
@@ -44,6 +44,7 @@ describe("DefaultCredentialGeneratorService", () => {
|
||||
beforeEach(() => {
|
||||
mockLogger = {
|
||||
info: jest.fn(),
|
||||
debug: jest.fn(),
|
||||
panic: jest.fn().mockImplementationOnce((c, m) => {
|
||||
throw new Error(m ?? c);
|
||||
}),
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import {
|
||||
EMPTY,
|
||||
combineLatest,
|
||||
concatMap,
|
||||
distinctUntilChanged,
|
||||
filter,
|
||||
@@ -54,7 +55,7 @@ export class DefaultCredentialGeneratorService implements CredentialGeneratorSer
|
||||
const account$ = dependencies.account$.pipe(shareReplay({ refCount: true, bufferSize: 1 }));
|
||||
|
||||
// load algorithm metadata
|
||||
const algorithm$ = on$.pipe(
|
||||
const metadata$ = on$.pipe(
|
||||
switchMap((requested) => {
|
||||
if (isAlgorithmRequest(requested)) {
|
||||
return of(requested.algorithm);
|
||||
@@ -71,17 +72,21 @@ export class DefaultCredentialGeneratorService implements CredentialGeneratorSer
|
||||
shareReplay({ refCount: true, bufferSize: 1 }),
|
||||
);
|
||||
|
||||
// load the active profile's algorithm settings
|
||||
const settings$ = on$.pipe(
|
||||
// load the active profile's settings
|
||||
const profile$ = on$.pipe(
|
||||
map((request) => request.profile ?? Profile.account),
|
||||
distinctUntilChanged(),
|
||||
withLatestReady(algorithm$),
|
||||
switchMap(([profile, meta]) => this.settings(meta, { account$ }, profile)),
|
||||
);
|
||||
const settings$ = combineLatest([metadata$, profile$]).pipe(
|
||||
tap(([metadata, profile]) =>
|
||||
this.log.debug({ algorithm: metadata.id, profile }, "settings loaded"),
|
||||
),
|
||||
switchMap(([metadata, profile]) => this.settings(metadata, { account$ }, profile)),
|
||||
);
|
||||
|
||||
// load the algorithm's engine
|
||||
const engine$ = algorithm$.pipe(
|
||||
tap((meta) => this.log.info({ algorithm: meta.id }, "engine selected")),
|
||||
const engine$ = metadata$.pipe(
|
||||
tap((metadata) => this.log.debug({ algorithm: metadata.id }, "engine selected")),
|
||||
map((meta) => meta.engine.create(this.provide.generator)),
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user