mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-22 18:00:18 +01:00
fixed multiple notification windows when executing batch
This commit is contained in:
parent
40b1688c67
commit
aaef2aeefd
@ -40,6 +40,7 @@ const isIE = !!document.documentMode
|
||||
const isEdge = !isIE && !!window.StyleMedia
|
||||
|
||||
let popupIsOpen = false
|
||||
let notifcationIsOpen = false;
|
||||
let openMetamaskTabsIDs = {}
|
||||
|
||||
// state persistence
|
||||
@ -136,6 +137,11 @@ function setupController (initState) {
|
||||
}
|
||||
})
|
||||
}
|
||||
if (remotePort.name === 'notification') {
|
||||
endOfStream(portStream, () => {
|
||||
notifcationIsOpen = false
|
||||
});
|
||||
}
|
||||
} else {
|
||||
// communication with page
|
||||
const originDomain = urlUtil.parse(remotePort.sender.url).hostname
|
||||
@ -178,7 +184,10 @@ function setupController (initState) {
|
||||
function triggerUi () {
|
||||
extension.tabs.query({ active: true }, (tabs) => {
|
||||
const currentlyActiveMetamaskTab = tabs.find(tab => openMetamaskTabsIDs[tab.id])
|
||||
if (!popupIsOpen && !currentlyActiveMetamaskTab) notificationManager.showPopup()
|
||||
if (!popupIsOpen && !currentlyActiveMetamaskTab) notificationManager.showPopup((notification) => {
|
||||
notifcationIsOpen = notification;
|
||||
});
|
||||
notifcationIsOpen = true;
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -9,7 +9,7 @@ class NotificationManager {
|
||||
// Public
|
||||
//
|
||||
|
||||
showPopup () {
|
||||
showPopup (cb) {
|
||||
this._getPopup((err, popup) => {
|
||||
if (err) throw err
|
||||
|
||||
@ -23,6 +23,9 @@ class NotificationManager {
|
||||
type: 'popup',
|
||||
width,
|
||||
height,
|
||||
}, (win) => {
|
||||
// naming of popup window and a popup in chrome extension sense is confusing
|
||||
cb((win.type == 'popup'));
|
||||
})
|
||||
}
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user