1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-09-27 04:03:00 +02:00
bitwarden-browser/apps/browser/src/autofill/background/context-menus.background.ts
Cesar Gonzalez de40e0687c
[PM-5949] Refactor Typing Information for Notification Bar (#7722)
* [PM-5949] Refactor typing information for notification bar

* [PM-5949] Fix jest tests for overlay background

* [PM-5949] Removing unnused typing data

* [PM-5949] Fixing lint error

* [PM-5949] Adding jest tests for convertAddLoginQueueMessageToCipherView method

* [PM-5949] Fixing jest test for overlay
2024-02-09 19:05:34 +00:00

46 lines
1.7 KiB
TypeScript

import { BrowserApi } from "../../platform/browser/browser-api";
import { ContextMenuClickedHandler } from "../browser/context-menu-clicked-handler";
import { LockedVaultPendingNotificationsData } from "./abstractions/notification.background";
export default class ContextMenusBackground {
private contextMenus: typeof chrome.contextMenus;
constructor(private contextMenuClickedHandler: ContextMenuClickedHandler) {
this.contextMenus = chrome.contextMenus;
}
init() {
if (!this.contextMenus) {
return;
}
this.contextMenus.onClicked.addListener((info, tab) =>
this.contextMenuClickedHandler.run(info, tab),
);
BrowserApi.messageListener(
"contextmenus.background",
(
msg: { command: string; data: LockedVaultPendingNotificationsData },
sender: chrome.runtime.MessageSender,
) => {
if (msg.command === "unlockCompleted" && msg.data.target === "contextmenus.background") {
// FIXME: Verify that this floating promise is intentional. If it is, add an explanatory comment and ensure there is proper error handling.
// eslint-disable-next-line @typescript-eslint/no-floating-promises
this.contextMenuClickedHandler
.cipherAction(
msg.data.commandToRetry.message.contextMenuOnClickData,
msg.data.commandToRetry.sender.tab,
)
.then(() => {
// FIXME: Verify that this floating promise is intentional. If it is, add an explanatory comment and ensure there is proper error handling.
// eslint-disable-next-line @typescript-eslint/no-floating-promises
BrowserApi.tabSendMessageData(sender.tab, "closeNotificationBar");
});
}
},
);
}
}