From 4c1b526137379969d16386f50ca3214d90c67c3f Mon Sep 17 00:00:00 2001 From: vittominacori Date: Sat, 16 Jun 2018 18:51:01 +0200 Subject: [PATCH 1/2] set an id to the metamask notification popup --- app/scripts/lib/notification-manager.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/scripts/lib/notification-manager.js b/app/scripts/lib/notification-manager.js index 5dfb42078..4a5d21e2f 100644 --- a/app/scripts/lib/notification-manager.js +++ b/app/scripts/lib/notification-manager.js @@ -28,6 +28,7 @@ class NotificationManager { } else { // create new notification popup extension.windows.create({ + id: 'metamask-popup', url: 'notification.html', type: 'popup', width, @@ -93,7 +94,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 === 'metamask-popup') }) : null } From ff3c2626213afa48151c43947087aae95298d5f6 Mon Sep 17 00:00:00 2001 From: vittominacori Date: Sun, 17 Jun 2018 19:16:30 +0200 Subject: [PATCH 2/2] set the popup id returned by create promise --- app/scripts/lib/notification-manager.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/scripts/lib/notification-manager.js b/app/scripts/lib/notification-manager.js index 4a5d21e2f..6b88a7a99 100644 --- a/app/scripts/lib/notification-manager.js +++ b/app/scripts/lib/notification-manager.js @@ -28,11 +28,12 @@ class NotificationManager { } else { // create new notification popup extension.windows.create({ - id: 'metamask-popup', url: 'notification.html', type: 'popup', width, height, + }).then((currentPopup) => { + this._popupId = currentPopup.id }) } }) @@ -85,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. @@ -94,7 +95,7 @@ class NotificationManager { _getPopupIn (windows) { return windows ? windows.find((win) => { // Returns notification popup - return (win && win.type === 'popup' && win.id === 'metamask-popup') + return (win && win.type === 'popup' && win.id === this._popupId) }) : null }