1
0
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:
Dan Finlay 2016-09-01 11:22:29 -07:00
parent d26dd53fe1
commit 47b2ae1c5f

View File

@ -9,11 +9,12 @@ module.exports = notifications
window.METAMASK_NOTIFIER = notifications window.METAMASK_NOTIFIER = notifications
function show () { function show () {
getPopup((popup) => { getWindows((windows) => {
if (popup) {
return extension.windows.update(popup.id, { focused: true })
}
if (windows.length > 0) {
const win = windows[0]
return extension.windows.update(win.id, { focused: true })
}
extension.windows.create({ extension.windows.create({
url: 'notification.html', url: 'notification.html',
@ -25,22 +26,29 @@ function show () {
}) })
} }
function getPopup(cb) { function getWindows(cb) {
// Ignore in test environment // Ignore in test environment
if (!extension.windows) { if (!extension.windows) {
return cb(null) return cb()
} }
extension.windows.getAll({}, (windows) => { extension.windows.getAll({}, (windows) => {
let popup = windows.find((win) => { cb(null, windows)
return win.type === 'popup'
}) })
}
cb(popup) function getPopup(cb) {
getWindows((windows) => {
cb(getPopupIn(windows))
}) })
} }
function getPopupIn(windows) {
return windows ? windows.find((win) => {
return win.type === 'popup'
}) : null
}
function closePopup() { function closePopup() {
getPopup((popup) => { getPopup((popup) => {
if (!popup) return if (!popup) return