mirror of
https://github.com/bitwarden/browser
synced 2025-12-16 16:23:44 +00:00
[PM-13723] track history in generator components (#11673)
* add history support to generator components * increase generator history length
This commit is contained in:
@@ -36,6 +36,7 @@ import {
|
||||
isUsernameAlgorithm,
|
||||
toCredentialGeneratorConfiguration,
|
||||
} from "@bitwarden/generator-core";
|
||||
import { GeneratorHistoryService } from "@bitwarden/generator-history";
|
||||
|
||||
// constants used to identify navigation selections that are not
|
||||
// generator algorithms
|
||||
@@ -57,6 +58,7 @@ export class UsernameGeneratorComponent implements OnInit, OnDestroy {
|
||||
*/
|
||||
constructor(
|
||||
private generatorService: CredentialGeneratorService,
|
||||
private generatorHistoryService: GeneratorHistoryService,
|
||||
private toastService: ToastService,
|
||||
private logService: LogService,
|
||||
private i18nService: I18nService,
|
||||
@@ -153,9 +155,16 @@ export class UsernameGeneratorComponent implements OnInit, OnDestroy {
|
||||
// continue with origin stream
|
||||
return generator;
|
||||
}),
|
||||
withLatestFrom(this.userId$),
|
||||
takeUntil(this.destroyed),
|
||||
)
|
||||
.subscribe((generated) => {
|
||||
.subscribe(([generated, userId]) => {
|
||||
this.generatorHistoryService
|
||||
.track(userId, generated.credential, generated.category, generated.generationDate)
|
||||
.catch((e: unknown) => {
|
||||
this.logService.error(e);
|
||||
});
|
||||
|
||||
// update subjects within the angular zone so that the
|
||||
// template bindings refresh immediately
|
||||
this.zone.run(() => {
|
||||
|
||||
Reference in New Issue
Block a user