mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Merge pull request #3306 from danjm/MM-805-send-from-tab-popup-fix
[NewUI] Prevents new tx from active tab from opening popup
This commit is contained in:
commit
e27a3823ba
@ -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…
Reference in New Issue
Block a user