aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/scripts/lib/notifications.js22
-rw-r--r--ui/app/reducers/app.js15
2 files changed, 22 insertions, 15 deletions
diff --git a/app/scripts/lib/notifications.js b/app/scripts/lib/notifications.js
index 4c2aa91de..cf4e1c216 100644
--- a/app/scripts/lib/notifications.js
+++ b/app/scripts/lib/notifications.js
@@ -2,19 +2,15 @@ const extension = require('./extension')
const notifications = {
show: showNotification,
+ getPopup,
}
module.exports = notifications
window.METAMASK_NOTIFIER = notifications
function showNotification() {
- extension.windows.getAll({}, (windows) => {
-
- let popupWindow = windows.find((win) => {
- return win.type === 'popup'
- })
-
- if (popupWindow) {
- return extension.windows.update(popupWindow.id, { focused: true })
+ getPopup((popup) => {
+ if (popup) {
+ return extension.windows.update(popup.id, { focused: true })
}
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)
+ })
+}
+
diff --git a/ui/app/reducers/app.js b/ui/app/reducers/app.js
index 94b7e8bf7..7bd1dfd1f 100644
--- a/ui/app/reducers/app.js
+++ b/ui/app/reducers/app.js
@@ -2,6 +2,7 @@ const extend = require('xtend')
const actions = require('../actions')
const txHelper = require('../../lib/tx-helper')
const extension = require('../../../app/scripts/lib/extension')
+const notification = require('../../../app/scripts/lib/notifications')
module.exports = reduceApp
@@ -252,12 +253,7 @@ function reduceApp (state, action) {
})
} else {
- const isNotification = window.METAMASK_UI_TYPE === 'notification'
- if (isNotification) {
- extension.windows.getCurrent({}, (win) => {
- extension.windows.remove(win.id, console.error)
- })
- }
+ closePopupIfOpen()
return extend(appState, {
transForward: false,
@@ -524,4 +520,9 @@ function indexForPending (state, txId) {
return idx
}
-
+function closePopupIfOpen() {
+ notification.getPopup((popup) => {
+ if (!popup) return
+ extension.windows.remove(popup.id, console.error)
+ })
+}