mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Do not open popup for internally produced txs
This commit is contained in:
parent
d26dd53fe1
commit
47b2ae1c5f
@ -9,11 +9,12 @@ module.exports = notifications
|
||||
window.METAMASK_NOTIFIER = notifications
|
||||
|
||||
function show () {
|
||||
getPopup((popup) => {
|
||||
if (popup) {
|
||||
return extension.windows.update(popup.id, { focused: true })
|
||||
}
|
||||
getWindows((windows) => {
|
||||
|
||||
if (windows.length > 0) {
|
||||
const win = windows[0]
|
||||
return extension.windows.update(win.id, { focused: true })
|
||||
}
|
||||
|
||||
extension.windows.create({
|
||||
url: 'notification.html',
|
||||
@ -25,22 +26,29 @@ function show () {
|
||||
})
|
||||
}
|
||||
|
||||
function getPopup(cb) {
|
||||
|
||||
function getWindows(cb) {
|
||||
// Ignore in test environment
|
||||
if (!extension.windows) {
|
||||
return cb(null)
|
||||
return cb()
|
||||
}
|
||||
|
||||
extension.windows.getAll({}, (windows) => {
|
||||
let popup = windows.find((win) => {
|
||||
return win.type === 'popup'
|
||||
})
|
||||
|
||||
cb(popup)
|
||||
cb(null, windows)
|
||||
})
|
||||
}
|
||||
|
||||
function getPopup(cb) {
|
||||
getWindows((windows) => {
|
||||
cb(getPopupIn(windows))
|
||||
})
|
||||
}
|
||||
|
||||
function getPopupIn(windows) {
|
||||
return windows ? windows.find((win) => {
|
||||
return win.type === 'popup'
|
||||
}) : null
|
||||
}
|
||||
|
||||
function closePopup() {
|
||||
getPopup((popup) => {
|
||||
if (!popup) return
|
||||
|
Loading…
Reference in New Issue
Block a user