Merge pull request #3306 from danjm/MM-805-send-from-tab-popup-fix

[NewUI] Prevents new tx from active tab from opening popup
feature/default_network_editable
Thomas Huang 7 years ago committed by GitHub
commit e27a3823ba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 12
      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.

Loading…
Cancel
Save