aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorkumavis <kumavis@users.noreply.github.com>2018-03-22 03:42:03 +0800
committerGitHub <noreply@github.com>2018-03-22 03:42:03 +0800
commit278e1ba61eab97860be295ad938cf47ce22f11ed (patch)
tree0d1f23170865e44409c8ee552ec41c993044a4ab /app
parenta80be4c8c37464ec6b5071482756f0cb7532924c (diff)
parent1343f5ede466c4fd8057795478ad21d0382d73cb (diff)
downloadtangerine-wallet-browser-278e1ba61eab97860be295ad938cf47ce22f11ed.tar
tangerine-wallet-browser-278e1ba61eab97860be295ad938cf47ce22f11ed.tar.gz
tangerine-wallet-browser-278e1ba61eab97860be295ad938cf47ce22f11ed.tar.bz2
tangerine-wallet-browser-278e1ba61eab97860be295ad938cf47ce22f11ed.tar.lz
tangerine-wallet-browser-278e1ba61eab97860be295ad938cf47ce22f11ed.tar.xz
tangerine-wallet-browser-278e1ba61eab97860be295ad938cf47ce22f11ed.tar.zst
tangerine-wallet-browser-278e1ba61eab97860be295ad938cf47ce22f11ed.zip
Merge pull request #3656 from MetaMask/trigun0x2-master2
Prevent batch request from opening multiple windows (3)
Diffstat (limited to 'app')
-rw-r--r--app/scripts/background.js9
-rw-r--r--app/scripts/lib/notification-manager.js11
-rw-r--r--app/scripts/popup.js1
3 files changed, 15 insertions, 6 deletions
diff --git a/app/scripts/background.js b/app/scripts/background.js
index ef5513ec7..8bd7766ad 100644
--- a/app/scripts/background.js
+++ b/app/scripts/background.js
@@ -42,6 +42,7 @@ const isIE = !!document.documentMode
const isEdge = !isIE && !!window.StyleMedia
let popupIsOpen = false
+let notificationIsOpen = false
let openMetamaskTabsIDs = {}
// state persistence
@@ -165,6 +166,11 @@ function setupController (initState) {
}
})
}
+ if (remotePort.name === 'notification') {
+ endOfStream(portStream, () => {
+ notificationIsOpen = false
+ })
+ }
} else {
// communication with page
const originDomain = urlUtil.parse(remotePort.sender.url).hostname
@@ -207,7 +213,8 @@ function setupController (initState) {
function triggerUi () {
extension.tabs.query({ active: true }, (tabs) => {
const currentlyActiveMetamaskTab = tabs.find(tab => openMetamaskTabsIDs[tab.id])
- if (!popupIsOpen && !currentlyActiveMetamaskTab) notificationManager.showPopup()
+ if (!popupIsOpen && !currentlyActiveMetamaskTab && !notificationIsOpen) notificationManager.showPopup()
+ notificationIsOpen = true
})
}
diff --git a/app/scripts/lib/notification-manager.js b/app/scripts/lib/notification-manager.js
index adaf60c65..1fcb7cf69 100644
--- a/app/scripts/lib/notification-manager.js
+++ b/app/scripts/lib/notification-manager.js
@@ -13,11 +13,12 @@ class NotificationManager {
this._getPopup((err, popup) => {
if (err) throw err
+ // Bring focus to chrome popup
if (popup) {
- // bring focus to existing popup
+ // bring focus to existing chrome popup
extension.windows.update(popup.id, { focused: true })
} else {
- // create new popup
+ // create new notification popup
extension.windows.create({
url: 'notification.html',
type: 'popup',
@@ -29,6 +30,7 @@ class NotificationManager {
}
closePopup () {
+ // closes notification popup
this._getPopup((err, popup) => {
if (err) throw err
if (!popup) return
@@ -60,9 +62,8 @@ class NotificationManager {
_getPopupIn (windows) {
return windows ? windows.find((win) => {
- return (win && win.type === 'popup' &&
- win.height === height &&
- win.width === width)
+ // Returns notification popup
+ return (win && win.type === 'popup')
}) : null
}
diff --git a/app/scripts/popup.js b/app/scripts/popup.js
index 11d50ee87..e78981f06 100644
--- a/app/scripts/popup.js
+++ b/app/scripts/popup.js
@@ -65,6 +65,7 @@ startPopup({ container, connectionStream }, (err, store) => {
function closePopupIfOpen (windowType) {
if (windowType !== 'notification') {
+ // should close only chrome popup
notificationManager.closePopup()
}
}