[PM-8833] Reworking how we handle adding a password to history
This commit is contained in:
parent
59e119bea0
commit
ab681e79eb
|
@ -191,6 +191,7 @@ describe("OverlayBackground", () => {
|
|||
inlineMenuFieldQualificationService,
|
||||
themeStateService,
|
||||
() => Promise.resolve(generatedPassword),
|
||||
() => Promise.resolve(),
|
||||
);
|
||||
portKeyForTabSpy = overlayBackground["portKeyForTab"];
|
||||
pageDetailsForTabSpy = overlayBackground["pageDetailsForTab"];
|
||||
|
|
|
@ -208,6 +208,7 @@ export class OverlayBackground implements OverlayBackgroundInterface {
|
|||
private inlineMenuFieldQualificationService: InlineMenuFieldQualificationService,
|
||||
private themeStateService: ThemeStateService,
|
||||
private generatePasswordCallback: () => Promise<string>,
|
||||
private addPasswordCallback: (password: string) => Promise<void>,
|
||||
) {
|
||||
this.initOverlayEventObservables();
|
||||
}
|
||||
|
@ -1536,6 +1537,8 @@ export class OverlayBackground implements OverlayBackgroundInterface {
|
|||
return;
|
||||
}
|
||||
|
||||
await this.addPasswordCallback(this.generatedPassword);
|
||||
|
||||
const pageDetails = this.pageDetailsForTab[port.sender.tab.id];
|
||||
if (!pageDetails) {
|
||||
return;
|
||||
|
|
|
@ -1621,6 +1621,7 @@ export default class MainBackground {
|
|||
inlineMenuFieldQualificationService,
|
||||
this.themeStateService,
|
||||
() => this.generatePassword(),
|
||||
(password) => this.addPasswordToHistory(password),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -1636,13 +1637,16 @@ export default class MainBackground {
|
|||
|
||||
generatePassword = async (): Promise<string> => {
|
||||
const options = (await this.passwordGenerationService.getOptions())?.[0] ?? {};
|
||||
const password = await this.passwordGenerationService.generatePassword(options);
|
||||
await this.passwordGenerationService.addHistory(password);
|
||||
|
||||
return password;
|
||||
return await this.passwordGenerationService.generatePassword(options);
|
||||
};
|
||||
|
||||
generatePasswordToClipboard = async () => {
|
||||
this.platformUtilsService.copyToClipboard(await this.generatePassword());
|
||||
const password = await this.generatePassword();
|
||||
this.platformUtilsService.copyToClipboard(password);
|
||||
await this.addPasswordToHistory(password);
|
||||
};
|
||||
|
||||
addPasswordToHistory = async (password: string) => {
|
||||
await this.passwordGenerationService.addHistory(password);
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue