[PM-8833] Refactoring implementation

This commit is contained in:
Cesar Gonzalez 2024-10-01 13:27:38 -05:00
parent 74ff56589e
commit 526966a3e0
No known key found for this signature in database
GPG Key ID: 3381A5457F8CCECF
1 changed files with 24 additions and 16 deletions

View File

@ -2666,17 +2666,11 @@ export class OverlayBackground implements OverlayBackgroundInterface {
const authStatus = await this.getAuthStatus();
const showInlineMenuAccountCreation = this.shouldShowInlineMenuAccountCreation();
const showInlineMenuPasswordGenerator = this.shouldShowInlineMenuPasswordGenerator(
const showInlineMenuPasswordGenerator = await this.shouldInitInlineMenuPasswordGenerator(
authStatus,
isInlineMenuListPort,
showInlineMenuAccountCreation,
);
if (
authStatus === AuthenticationStatus.Unlocked &&
showInlineMenuPasswordGenerator &&
!this.generatedPassword
) {
await this.generatePassword();
}
this.storeOverlayPort(port);
port.onDisconnect.addListener(this.handlePortOnDisconnect);
@ -2744,21 +2738,35 @@ export class OverlayBackground implements OverlayBackgroundInterface {
}
/**
* Identifies if the focused field should show the inline menu password generator.
* Identifies if the focused field should show the inline menu
* password generator when the inline menu is opened.
*
* @param authStatus - The current authentication status
* @param isInlineMenuListPort - Identifies if the port is for the inline menu list
* @param showInlineMenuAccountCreation - Identifies if the inline menu account creation should be shown
*/
private shouldShowInlineMenuPasswordGenerator(
private async shouldInitInlineMenuPasswordGenerator(
authStatus: AuthenticationStatus,
isInlineMenuListPort: boolean,
showInlineMenuAccountCreation: boolean,
) {
return (
isInlineMenuListPort &&
(this.focusedFieldMatchesFillType(InlineMenuFillType.PasswordGeneration) ||
(showInlineMenuAccountCreation &&
this.focusedFieldMatchesAccountCreationType(InlineMenuAccountCreationFieldType.Password)))
);
if (!isInlineMenuListPort || authStatus !== AuthenticationStatus.Unlocked) {
return false;
}
const focusFieldShouldShowPasswordGenerator =
this.focusedFieldMatchesFillType(InlineMenuFillType.PasswordGeneration) ||
(showInlineMenuAccountCreation &&
this.focusedFieldMatchesAccountCreationType(InlineMenuAccountCreationFieldType.Password));
if (!focusFieldShouldShowPasswordGenerator) {
return false;
}
if (!this.generatedPassword) {
await this.generatePassword();
}
return true;
}
/**