From 7e4950b18444369f62cbff1f49ba154306fff6fb Mon Sep 17 00:00:00 2001 From: Kendall Werts Date: Wed, 23 Oct 2019 15:48:43 -0500 Subject: [PATCH] menu updates when containers are changed, added, or deleted. Tests need to be updated --- src/js/background/assignManager.js | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/src/js/background/assignManager.js b/src/js/background/assignManager.js index 659ecf7..b65f811 100644 --- a/src/js/background/assignManager.js +++ b/src/js/background/assignManager.js @@ -246,9 +246,30 @@ const assignManager = { delete this.canceledRequests[options.tabId]; } },{urls: [""], types: ["main_frame"]}); - this.initBookmarksMenu(); + browser.contextualIdentities.onCreated.addListener(this.contextualIdentCreated); + browser.contextualIdentities.onUpdated.addListener(this.contextualIdentUpdated); + browser.contextualIdentities.onRemoved.addListener(this.contextualIdentRemoved); + }, + contextualIdentCreated(changeInfo) { + browser.contextMenus.create({ + parentId: assignManager.OPEN_IN_CONTAINER, + id: changeInfo.contextualIdentity.cookieStoreId, + title: changeInfo.contextualIdentity.name, + icons: { "16": `img/usercontext.svg#${changeInfo.contextualIdentity.icon}` } + }); + }, + + contextualIdentUpdated(changeInfo) { + browser.contextMenus.update(changeInfo.contextualIdentity.cookieStoreId, { + title: changeInfo.contextualIdentity.name, + icons: { "16": `img/usercontext.svg#${changeInfo.contextualIdentity.icon}` } + }); + }, + + contextualIdentRemoved(changeInfo) { + browser.contextMenus.remove(changeInfo.contextualIdentity.cookieStoreId); }, async _onClickedHandler(info, tab) { @@ -477,7 +498,7 @@ const assignManager = { parentId: this.OPEN_IN_CONTAINER, id: identity.cookieStoreId, title: identity.name, - icons: { "16": `img/usercontext.svg#${identity.icon}` } + icons: { "16": `img/usercontext.svg#${identity.icon}` } }); } }