From 0e832ee4351312f6cc26bbcc07aa0ca3ca1492dd Mon Sep 17 00:00:00 2001 From: Daniel James Smith Date: Tue, 19 Oct 2021 16:08:40 +0200 Subject: [PATCH] Remove noop - openPopup and use promptForLogin instead when vault is locked --- src/background/contextMenus.background.ts | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/background/contextMenus.background.ts b/src/background/contextMenus.background.ts index 146601b58ad..5ec1b46fbe4 100644 --- a/src/background/contextMenus.background.ts +++ b/src/background/contextMenus.background.ts @@ -11,6 +11,7 @@ import { VaultTimeoutService } from 'jslib-common/abstractions/vaultTimeout.serv import { EventType } from 'jslib-common/enums/eventType'; import { CipherView } from 'jslib-common/models/view/cipherView'; +import LockedVaultPendingNotificationsItem from './models/lockedVaultPendingNotificationsItem'; export default class ContextMenusBackground { private contextMenus: any; @@ -58,14 +59,18 @@ export default class ContextMenusBackground { private async cipherAction(tab: chrome.tabs.Tab, info: chrome.contextMenus.OnClickData) { const id = info.menuItemId.split('_')[1]; - if (id === 'noop') { - if (chrome.browserAction && (chrome.browserAction as any).openPopup) { - (chrome.browserAction as any).openPopup(); - } - return; - } if (await this.vaultTimeoutService.isLocked()) { + const retryMessage: LockedVaultPendingNotificationsItem = { + commandToRetry: { + msg: { command: 'noop', data: info }, + sender: { tab: tab }, + }, + target: 'contextmenus.background', + }; + await BrowserApi.tabSendMessageData(tab, 'addToLockedVaultPendingNotifications', retryMessage); + + BrowserApi.tabSendMessageData(tab, 'promptForLogin'); return; }