|
|
@ -40,6 +40,7 @@ const isIE = !!document.documentMode |
|
|
|
const isEdge = !isIE && !!window.StyleMedia |
|
|
|
const isEdge = !isIE && !!window.StyleMedia |
|
|
|
|
|
|
|
|
|
|
|
let popupIsOpen = false |
|
|
|
let popupIsOpen = false |
|
|
|
|
|
|
|
let notifcationIsOpen = false; |
|
|
|
let openMetamaskTabsIDs = {} |
|
|
|
let openMetamaskTabsIDs = {} |
|
|
|
|
|
|
|
|
|
|
|
// state persistence
|
|
|
|
// state persistence
|
|
|
@ -136,6 +137,11 @@ function setupController (initState) { |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (remotePort.name === 'notification') { |
|
|
|
|
|
|
|
endOfStream(portStream, () => { |
|
|
|
|
|
|
|
notifcationIsOpen = false |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
// communication with page
|
|
|
|
// communication with page
|
|
|
|
const originDomain = urlUtil.parse(remotePort.sender.url).hostname |
|
|
|
const originDomain = urlUtil.parse(remotePort.sender.url).hostname |
|
|
@ -178,7 +184,10 @@ function setupController (initState) { |
|
|
|
function triggerUi () { |
|
|
|
function triggerUi () { |
|
|
|
extension.tabs.query({ active: true }, (tabs) => { |
|
|
|
extension.tabs.query({ active: true }, (tabs) => { |
|
|
|
const currentlyActiveMetamaskTab = tabs.find(tab => openMetamaskTabsIDs[tab.id]) |
|
|
|
const currentlyActiveMetamaskTab = tabs.find(tab => openMetamaskTabsIDs[tab.id]) |
|
|
|
if (!popupIsOpen && !currentlyActiveMetamaskTab) notificationManager.showPopup() |
|
|
|
if (!popupIsOpen && !currentlyActiveMetamaskTab) notificationManager.showPopup((notification) => { |
|
|
|
|
|
|
|
notifcationIsOpen = notification; |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
notifcationIsOpen = true; |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|