aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts/lib/notification-manager.js
diff options
context:
space:
mode:
Diffstat (limited to 'app/scripts/lib/notification-manager.js')
-rw-r--r--app/scripts/lib/notification-manager.js10
1 files changed, 6 insertions, 4 deletions
diff --git a/app/scripts/lib/notification-manager.js b/app/scripts/lib/notification-manager.js
index 5dfb42078..969a9459a 100644
--- a/app/scripts/lib/notification-manager.js
+++ b/app/scripts/lib/notification-manager.js
@@ -26,13 +26,15 @@ class NotificationManager {
// bring focus to existing chrome popup
extension.windows.update(popup.id, { focused: true })
} else {
+ const cb = (currentPopup) => { this._popupId = currentPopup.id }
// create new notification popup
- extension.windows.create({
+ const creation = extension.windows.create({
url: 'notification.html',
type: 'popup',
width,
height,
- })
+ }, cb)
+ creation && creation.then && creation.then(cb)
}
})
}
@@ -84,7 +86,7 @@ class NotificationManager {
}
/**
- * Given an array of windows, returns the first that has a 'popup' type, or null if no such window exists.
+ * Given an array of windows, returns the 'popup' that has been opened by MetaMask, or null if no such window exists.
*
* @private
* @param {array} windows An array of objects containing data about the open MetaMask extension windows.
@@ -93,7 +95,7 @@ class NotificationManager {
_getPopupIn (windows) {
return windows ? windows.find((win) => {
// Returns notification popup
- return (win && win.type === 'popup')
+ return (win && win.type === 'popup' && win.id === this._popupId)
}) : null
}