aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorkumavis <aaron@kumavis.me>2018-03-22 02:55:09 +0800
committerkumavis <aaron@kumavis.me>2018-03-22 02:55:09 +0800
commit5d3246c836f3634f2b78bc1d511a797c4d3c9ee7 (patch)
tree0546f12279fb855a3b148a785a3c49e8312ea064 /app
parentec1188f25017b6b352744646aee61155d84fc999 (diff)
parent93495b28098701e5558052b7f39c39993dc64911 (diff)
downloadtangerine-wallet-browser-5d3246c836f3634f2b78bc1d511a797c4d3c9ee7.tar.gz
tangerine-wallet-browser-5d3246c836f3634f2b78bc1d511a797c4d3c9ee7.tar.zst
tangerine-wallet-browser-5d3246c836f3634f2b78bc1d511a797c4d3c9ee7.zip
Merge branch 'master' of https://github.com/trigun0x2/metamask-extension into trigun0x2-master
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()
}
}