aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorDan <danjm.com@gmail.com>2018-02-22 02:24:00 +0800
committerDan <danjm.com@gmail.com>2018-02-22 02:34:04 +0800
commita4ed6af2ad9469a29e100f9246e8960b078cff46 (patch)
tree29864075cc9d6c4f3b052749d2aefa46ea96b341 /app
parent13b12efa033a7961d59372bd53473f6251458d98 (diff)
downloadtangerine-wallet-browser-a4ed6af2ad9469a29e100f9246e8960b078cff46.tar
tangerine-wallet-browser-a4ed6af2ad9469a29e100f9246e8960b078cff46.tar.gz
tangerine-wallet-browser-a4ed6af2ad9469a29e100f9246e8960b078cff46.tar.bz2
tangerine-wallet-browser-a4ed6af2ad9469a29e100f9246e8960b078cff46.tar.lz
tangerine-wallet-browser-a4ed6af2ad9469a29e100f9246e8960b078cff46.tar.xz
tangerine-wallet-browser-a4ed6af2ad9469a29e100f9246e8960b078cff46.tar.zst
tangerine-wallet-browser-a4ed6af2ad9469a29e100f9246e8960b078cff46.zip
Prevents new transaction from generating popup when metamask is open in an active tab.
Diffstat (limited to 'app')
-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 0471cee3b..816c655a1 100644
--- a/app/scripts/background.js
+++ b/app/scripts/background.js
@@ -30,6 +30,7 @@ const release = platform.getVersion()
const raven = setupRaven({ release })
let popupIsOpen = false
+let openMetamaskTabsIDs = {}
// state persistence
const diskStore = new LocalStorageStore({ storageKey: STORAGE_KEY })
@@ -113,9 +114,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 {
@@ -158,7 +165,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.