From 4e18faaba0bacc05fa86d68e01305e7868657b91 Mon Sep 17 00:00:00 2001 From: Miles Blackwood Date: Tue, 3 Jun 2025 18:21:41 -0400 Subject: [PATCH] Only clear web request after all notification types are attempted. Colocate remov able types alongside the method concerned with them. --- .../background/overlay-notifications.background.ts | 10 +++------- .../overlay-notifications-content.service.ts | 13 ++++++++++--- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/apps/browser/src/autofill/background/overlay-notifications.background.ts b/apps/browser/src/autofill/background/overlay-notifications.background.ts index b3d6f3e1bf3..93357113fc4 100644 --- a/apps/browser/src/autofill/background/overlay-notifications.background.ts +++ b/apps/browser/src/autofill/background/overlay-notifications.background.ts @@ -434,9 +434,7 @@ export class OverlayNotificationsBackground implements OverlayNotificationsBackg }, { tab }, ); - if (success) { - this.clearCompletedWebRequest(requestId, tab); - } else { + if (!success) { result = "Unqualified changedPassword notification attempt."; } } @@ -453,9 +451,7 @@ export class OverlayNotificationsBackground implements OverlayNotificationsBackg }, { tab }, ); - if (success) { - this.clearCompletedWebRequest(requestId, tab); - } else { + if (!success) { result = "Unqualified addLogin notification attempt."; } } @@ -486,12 +482,12 @@ export class OverlayNotificationsBackground implements OverlayNotificationsBackg }, { tab }, ); - this.clearCompletedWebRequest(requestId, tab); } else { result = "Unqualified atRiskPassword notification attempt."; } } } + this.clearCompletedWebRequest(requestId, tab); return result; }; diff --git a/apps/browser/src/autofill/overlay/notifications/content/overlay-notifications-content.service.ts b/apps/browser/src/autofill/overlay/notifications/content/overlay-notifications-content.service.ts index 31a45118a6c..03b99f784d7 100644 --- a/apps/browser/src/autofill/overlay/notifications/content/overlay-notifications-content.service.ts +++ b/apps/browser/src/autofill/overlay/notifications/content/overlay-notifications-content.service.ts @@ -5,6 +5,7 @@ import { EVENTS } from "@bitwarden/common/autofill/constants"; import { NotificationBarIframeInitData, NotificationType, + NotificationTypes, } from "../../../notification/abstractions/notification-bar"; import { sendExtensionMessage, setElementStyles } from "../../../utils"; import { @@ -18,8 +19,7 @@ export class OverlayNotificationsContentService { private notificationBarElement: HTMLElement | null = null; private notificationBarIframeElement: HTMLIFrameElement | null = null; - private currentNotificationBarType: string | null = null; - private removeTabFromNotificationQueueTypes = new Set(["add", "change"]); + private currentNotificationBarType: NotificationType | null = null; private notificationRefreshFlag: boolean = false; private notificationBarElementStyles: Partial = { height: "82px", @@ -296,9 +296,16 @@ export class OverlayNotificationsContentService this.notificationBarElement.remove(); this.notificationBarElement = null; + // Exclude Unlock + const removableNotificationTypes = [ + NotificationTypes.Add, + NotificationTypes.Change, + NotificationTypes.AtRiskPassword, + ]; + if ( closedByUserAction && - this.removeTabFromNotificationQueueTypes.has(this.currentNotificationBarType) + removableNotificationTypes.some((nt) => nt === this.currentNotificationBarType) ) { void sendExtensionMessage("bgRemoveTabFromNotificationQueue"); }