aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Huang <tmashuang@users.noreply.github.com>2018-02-22 04:50:45 +0800
committerGitHub <noreply@github.com>2018-02-22 04:50:45 +0800
commite27a3823ba2595baa7c3378e6a6f2aa5dae30250 (patch)
treec7cfc9bea782df7035761caa8c1809d8fde58824
parent8da20e15bdbc3bad22c7b1f0187b96b2b42ed388 (diff)
parenta4ed6af2ad9469a29e100f9246e8960b078cff46 (diff)
downloadtangerine-wallet-browser-e27a3823ba2595baa7c3378e6a6f2aa5dae30250.tar.gz
tangerine-wallet-browser-e27a3823ba2595baa7c3378e6a6f2aa5dae30250.tar.zst
tangerine-wallet-browser-e27a3823ba2595baa7c3378e6a6f2aa5dae30250.zip
Merge pull request #3306 from danjm/MM-805-send-from-tab-popup-fix
[NewUI] Prevents new tx from active tab from opening popup
-rw-r--r--app/scripts/background.js12
1 files changed, 11 insertions, 1 deletions
diff --git a/app/scripts/background.js b/app/scripts/background.js
index 6bf7707e8..71ada8405 100644
--- a/app/scripts/background.js
+++ b/app/scripts/background.js
@@ -31,6 +31,7 @@ const release = platform.getVersion()
const raven = setupRaven({ release })
let popupIsOpen = false
+let openMetamaskTabsIDs = {}
// state persistence
const diskStore = new LocalStorageStore({ storageKey: STORAGE_KEY })
@@ -117,9 +118,15 @@ function setupController (initState) {
popupIsOpen = popupIsOpen || (remotePort.name === 'popup')
controller.setupTrustedCommunication(portStream, 'MetaMask')
// record popup as closed
+ if (remotePort.sender.url.match(/home.html$/)) {
+ openMetamaskTabsIDs[remotePort.sender.tab.id] = true
+ }
if (remotePort.name === 'popup') {
endOfStream(portStream, () => {
popupIsOpen = false
+ if (remotePort.sender.url.match(/home.html$/)) {
+ openMetamaskTabsIDs[remotePort.sender.tab.id] = false
+ }
})
}
} else {
@@ -162,7 +169,10 @@ function setupController (initState) {
// popup trigger
function triggerUi () {
- if (!popupIsOpen) notificationManager.showPopup()
+ extension.tabs.query({ active: true }, (tabs) => {
+ const currentlyActiveMetamaskTab = tabs.find(tab => openMetamaskTabsIDs[tab.id])
+ if (!popupIsOpen && !currentlyActiveMetamaskTab) notificationManager.showPopup()
+ })
}
// On first install, open a window to MetaMask website to how-it-works.