mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Close popup even if last tx is dismissed from main UI
This commit is contained in:
parent
e5ca83d2bf
commit
4fb49dfb4b
@ -2,19 +2,15 @@ const extension = require('./extension')
|
|||||||
|
|
||||||
const notifications = {
|
const notifications = {
|
||||||
show: showNotification,
|
show: showNotification,
|
||||||
|
getPopup,
|
||||||
}
|
}
|
||||||
module.exports = notifications
|
module.exports = notifications
|
||||||
window.METAMASK_NOTIFIER = notifications
|
window.METAMASK_NOTIFIER = notifications
|
||||||
|
|
||||||
function showNotification() {
|
function showNotification() {
|
||||||
extension.windows.getAll({}, (windows) => {
|
getPopup((popup) => {
|
||||||
|
if (popup) {
|
||||||
let popupWindow = windows.find((win) => {
|
return extension.windows.update(popup.id, { focused: true })
|
||||||
return win.type === 'popup'
|
|
||||||
})
|
|
||||||
|
|
||||||
if (popupWindow) {
|
|
||||||
return extension.windows.update(popupWindow.id, { focused: true })
|
|
||||||
}
|
}
|
||||||
|
|
||||||
extension.windows.create({
|
extension.windows.create({
|
||||||
@ -27,3 +23,13 @@ function showNotification() {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getPopup(cb) {
|
||||||
|
extension.windows.getAll({}, (windows) => {
|
||||||
|
let popup = windows.find((win) => {
|
||||||
|
return win.type === 'popup'
|
||||||
|
})
|
||||||
|
|
||||||
|
cb(popup)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@ const extend = require('xtend')
|
|||||||
const actions = require('../actions')
|
const actions = require('../actions')
|
||||||
const txHelper = require('../../lib/tx-helper')
|
const txHelper = require('../../lib/tx-helper')
|
||||||
const extension = require('../../../app/scripts/lib/extension')
|
const extension = require('../../../app/scripts/lib/extension')
|
||||||
|
const notification = require('../../../app/scripts/lib/notifications')
|
||||||
|
|
||||||
module.exports = reduceApp
|
module.exports = reduceApp
|
||||||
|
|
||||||
@ -252,12 +253,7 @@ function reduceApp (state, action) {
|
|||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
const isNotification = window.METAMASK_UI_TYPE === 'notification'
|
closePopupIfOpen()
|
||||||
if (isNotification) {
|
|
||||||
extension.windows.getCurrent({}, (win) => {
|
|
||||||
extension.windows.remove(win.id, console.error)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
return extend(appState, {
|
return extend(appState, {
|
||||||
transForward: false,
|
transForward: false,
|
||||||
@ -524,4 +520,9 @@ function indexForPending (state, txId) {
|
|||||||
return idx
|
return idx
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function closePopupIfOpen() {
|
||||||
|
notification.getPopup((popup) => {
|
||||||
|
if (!popup) return
|
||||||
|
extension.windows.remove(popup.id, console.error)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user