mirror of
https://github.com/bitwarden/browser
synced 2025-12-16 08:13:42 +00:00
[PM-5189] Reworking how we handle updating ciphers on unlock and updating reference to auth status to use observable
This commit is contained in:
@@ -395,7 +395,7 @@ describe("OverlayBackground", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("skips updating the inline menu list if the focused field has a value and the user status is not unlocked", async () => {
|
it("skips updating the inline menu list if the focused field has a value and the user status is not unlocked", async () => {
|
||||||
overlayBackground["userAuthStatus"] = AuthenticationStatus.Locked;
|
activeAccountStatusMock$.next(AuthenticationStatus.Locked);
|
||||||
tabsSendMessageSpy.mockImplementation((_tab, message, _options) => {
|
tabsSendMessageSpy.mockImplementation((_tab, message, _options) => {
|
||||||
if (message.command === "checkMostRecentlyFocusedFieldHasValue") {
|
if (message.command === "checkMostRecentlyFocusedFieldHasValue") {
|
||||||
return Promise.resolve(true);
|
return Promise.resolve(true);
|
||||||
@@ -425,4 +425,6 @@ describe("OverlayBackground", () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe("updateOverlayCiphers", () => {});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -54,7 +54,6 @@ export class OverlayBackground implements OverlayBackgroundInterface {
|
|||||||
private subFrameOffsetsForTab: SubFrameOffsetsForTab = {};
|
private subFrameOffsetsForTab: SubFrameOffsetsForTab = {};
|
||||||
private updateInlineMenuPositionTimeout: number | NodeJS.Timeout;
|
private updateInlineMenuPositionTimeout: number | NodeJS.Timeout;
|
||||||
private inlineMenuFadeInTimeout: number | NodeJS.Timeout;
|
private inlineMenuFadeInTimeout: number | NodeJS.Timeout;
|
||||||
private userAuthStatus: AuthenticationStatus = AuthenticationStatus.LoggedOut;
|
|
||||||
private inlineMenuButtonPort: chrome.runtime.Port;
|
private inlineMenuButtonPort: chrome.runtime.Port;
|
||||||
private inlineMenuListPort: chrome.runtime.Port;
|
private inlineMenuListPort: chrome.runtime.Port;
|
||||||
private expiredPorts: chrome.runtime.Port[] = [];
|
private expiredPorts: chrome.runtime.Port[] = [];
|
||||||
@@ -393,7 +392,7 @@ export class OverlayBackground implements OverlayBackgroundInterface {
|
|||||||
if (
|
if (
|
||||||
mostRecentlyFocusedFieldHasValue &&
|
mostRecentlyFocusedFieldHasValue &&
|
||||||
(this.checkIsOverlayLoginCiphersPopulated(sender) ||
|
(this.checkIsOverlayLoginCiphersPopulated(sender) ||
|
||||||
this.userAuthStatus !== AuthenticationStatus.Unlocked)
|
(await this.getAuthStatus()) !== AuthenticationStatus.Unlocked)
|
||||||
) {
|
) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -742,27 +741,16 @@ export class OverlayBackground implements OverlayBackgroundInterface {
|
|||||||
* and the inline menu list's ciphers will be updated.
|
* and the inline menu list's ciphers will be updated.
|
||||||
*/
|
*/
|
||||||
private async getAuthStatus() {
|
private async getAuthStatus() {
|
||||||
const formerAuthStatus = this.userAuthStatus;
|
return await firstValueFrom(this.authService.activeAccountStatus$);
|
||||||
this.userAuthStatus = await firstValueFrom(this.authService.activeAccountStatus$);
|
|
||||||
|
|
||||||
if (
|
|
||||||
this.userAuthStatus !== formerAuthStatus &&
|
|
||||||
this.userAuthStatus === AuthenticationStatus.Unlocked
|
|
||||||
) {
|
|
||||||
this.updateInlineMenuButtonAuthStatus();
|
|
||||||
await this.updateOverlayCiphers();
|
|
||||||
}
|
|
||||||
|
|
||||||
return this.userAuthStatus;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sends a message to the inline menu button to update its authentication status.
|
* Sends a message to the inline menu button to update its authentication status.
|
||||||
*/
|
*/
|
||||||
private updateInlineMenuButtonAuthStatus() {
|
private async updateInlineMenuButtonAuthStatus() {
|
||||||
this.inlineMenuButtonPort?.postMessage({
|
this.inlineMenuButtonPort?.postMessage({
|
||||||
command: "updateInlineMenuButtonAuthStatus",
|
command: "updateInlineMenuButtonAuthStatus",
|
||||||
authStatus: this.userAuthStatus,
|
authStatus: await this.getAuthStatus(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -773,13 +761,13 @@ export class OverlayBackground implements OverlayBackgroundInterface {
|
|||||||
*
|
*
|
||||||
* @param port - The port of the inline menu button
|
* @param port - The port of the inline menu button
|
||||||
*/
|
*/
|
||||||
private handleInlineMenuButtonClicked(port: chrome.runtime.Port) {
|
private async handleInlineMenuButtonClicked(port: chrome.runtime.Port) {
|
||||||
if (this.userAuthStatus !== AuthenticationStatus.Unlocked) {
|
if ((await this.getAuthStatus()) !== AuthenticationStatus.Unlocked) {
|
||||||
void this.unlockVault(port);
|
await this.unlockVault(port);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void this.openInlineMenu(false, true);
|
await this.openInlineMenu(false, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -839,6 +827,8 @@ export class OverlayBackground implements OverlayBackgroundInterface {
|
|||||||
*/
|
*/
|
||||||
private async unlockCompleted(message: OverlayBackgroundExtensionMessage) {
|
private async unlockCompleted(message: OverlayBackgroundExtensionMessage) {
|
||||||
await this.getAuthStatus();
|
await this.getAuthStatus();
|
||||||
|
await this.updateInlineMenuButtonAuthStatus();
|
||||||
|
await this.updateOverlayCiphers();
|
||||||
|
|
||||||
if (message.data?.commandToRetry?.message?.command === "openAutofillInlineMenu") {
|
if (message.data?.commandToRetry?.message?.command === "openAutofillInlineMenu") {
|
||||||
await this.openInlineMenu(true);
|
await this.openInlineMenu(true);
|
||||||
|
|||||||
Reference in New Issue
Block a user