From 40b1688c67bfb820aca437751dda87df98e9513a Mon Sep 17 00:00:00 2001 From: Jeffrey Tong Date: Wed, 7 Mar 2018 14:19:27 -0800 Subject: removed check for width & height on multiple popup windows --- app/scripts/lib/notification-manager.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/app/scripts/lib/notification-manager.js b/app/scripts/lib/notification-manager.js index adaf60c65..1283933e1 100644 --- a/app/scripts/lib/notification-manager.js +++ b/app/scripts/lib/notification-manager.js @@ -60,9 +60,7 @@ class NotificationManager { _getPopupIn (windows) { return windows ? windows.find((win) => { - return (win && win.type === 'popup' && - win.height === height && - win.width === width) + return (win && win.type === 'popup') }) : null } -- cgit v1.2.3 From aaef2aeefde39ce11ef07603fd1cb5d2cbb1e294 Mon Sep 17 00:00:00 2001 From: Jeffrey Tong Date: Wed, 7 Mar 2018 20:09:40 -0800 Subject: fixed multiple notification windows when executing batch --- app/scripts/background.js | 11 ++++++++++- app/scripts/lib/notification-manager.js | 5 ++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/app/scripts/background.js b/app/scripts/background.js index 601ae0372..6cb80244f 100644 --- a/app/scripts/background.js +++ b/app/scripts/background.js @@ -40,6 +40,7 @@ const isIE = !!document.documentMode const isEdge = !isIE && !!window.StyleMedia let popupIsOpen = false +let notifcationIsOpen = false; let openMetamaskTabsIDs = {} // state persistence @@ -136,6 +137,11 @@ function setupController (initState) { } }) } + if (remotePort.name === 'notification') { + endOfStream(portStream, () => { + notifcationIsOpen = false + }); + } } else { // communication with page const originDomain = urlUtil.parse(remotePort.sender.url).hostname @@ -178,7 +184,10 @@ 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) notificationManager.showPopup((notification) => { + notifcationIsOpen = notification; + }); + notifcationIsOpen = true; }) } diff --git a/app/scripts/lib/notification-manager.js b/app/scripts/lib/notification-manager.js index 1283933e1..351f82694 100644 --- a/app/scripts/lib/notification-manager.js +++ b/app/scripts/lib/notification-manager.js @@ -9,7 +9,7 @@ class NotificationManager { // Public // - showPopup () { + showPopup (cb) { this._getPopup((err, popup) => { if (err) throw err @@ -23,6 +23,9 @@ class NotificationManager { type: 'popup', width, height, + }, (win) => { + // naming of popup window and a popup in chrome extension sense is confusing + cb((win.type == 'popup')); }) } }) -- cgit v1.2.3 From bda493dc9dc7436e5169a3344d8a72eb3c8d48d8 Mon Sep 17 00:00:00 2001 From: Jeffrey Tong Date: Sun, 11 Mar 2018 10:17:08 -0700 Subject: add comments that need clarification on naming convention --- app/scripts/background.js | 4 +--- app/scripts/lib/notification-manager.js | 14 ++++++++------ app/scripts/popup.js | 1 + 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/app/scripts/background.js b/app/scripts/background.js index 6cb80244f..679c2a4e2 100644 --- a/app/scripts/background.js +++ b/app/scripts/background.js @@ -184,9 +184,7 @@ function setupController (initState) { function triggerUi () { extension.tabs.query({ active: true }, (tabs) => { const currentlyActiveMetamaskTab = tabs.find(tab => openMetamaskTabsIDs[tab.id]) - if (!popupIsOpen && !currentlyActiveMetamaskTab) notificationManager.showPopup((notification) => { - notifcationIsOpen = notification; - }); + if (!popupIsOpen && !currentlyActiveMetamaskTab) notificationManager.showPopup(); notifcationIsOpen = true; }) } diff --git a/app/scripts/lib/notification-manager.js b/app/scripts/lib/notification-manager.js index 351f82694..0087a1dbb 100644 --- a/app/scripts/lib/notification-manager.js +++ b/app/scripts/lib/notification-manager.js @@ -9,29 +9,28 @@ class NotificationManager { // Public // - showPopup (cb) { + showPopup () { 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', width, height, - }, (win) => { - // naming of popup window and a popup in chrome extension sense is confusing - cb((win.type == 'popup')); }) } }) } closePopup () { + // closes notification popup this._getPopup((err, popup) => { if (err) throw err if (!popup) return @@ -46,6 +45,7 @@ class NotificationManager { _getPopup (cb) { this._getWindows((err, windows) => { if (err) throw err + console.log(windows); cb(null, this._getPopupIn(windows)) }) } @@ -63,6 +63,8 @@ class NotificationManager { _getPopupIn (windows) { return windows ? windows.find((win) => { + // Returns notification popup + console.log(win); 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() } } -- cgit v1.2.3 From 4f853bbd3c374df7c2991d5fdf91112f6f319bb3 Mon Sep 17 00:00:00 2001 From: Jeffrey Tong Date: Sun, 11 Mar 2018 10:18:55 -0700 Subject: remove console log --- app/scripts/lib/notification-manager.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/scripts/lib/notification-manager.js b/app/scripts/lib/notification-manager.js index 0087a1dbb..1fcb7cf69 100644 --- a/app/scripts/lib/notification-manager.js +++ b/app/scripts/lib/notification-manager.js @@ -45,7 +45,6 @@ class NotificationManager { _getPopup (cb) { this._getWindows((err, windows) => { if (err) throw err - console.log(windows); cb(null, this._getPopupIn(windows)) }) } @@ -64,7 +63,6 @@ class NotificationManager { _getPopupIn (windows) { return windows ? windows.find((win) => { // Returns notification popup - console.log(win); return (win && win.type === 'popup') }) : null } -- cgit v1.2.3 From 93495b28098701e5558052b7f39c39993dc64911 Mon Sep 17 00:00:00 2001 From: Jeffrey Tong Date: Tue, 20 Mar 2018 12:18:48 -0700 Subject: fix for lint --- app/scripts/background.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/scripts/background.js b/app/scripts/background.js index 679c2a4e2..53b67f294 100644 --- a/app/scripts/background.js +++ b/app/scripts/background.js @@ -40,7 +40,7 @@ const isIE = !!document.documentMode const isEdge = !isIE && !!window.StyleMedia let popupIsOpen = false -let notifcationIsOpen = false; +let notificationIsOpen = false let openMetamaskTabsIDs = {} // state persistence @@ -139,8 +139,8 @@ function setupController (initState) { } if (remotePort.name === 'notification') { endOfStream(portStream, () => { - notifcationIsOpen = false - }); + notificationIsOpen = false + }) } } else { // communication with page @@ -184,8 +184,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(); - notifcationIsOpen = true; + if (!popupIsOpen && !currentlyActiveMetamaskTab && !notificationIsOpen) notificationManager.showPopup() + notificationIsOpen = true }) } -- cgit v1.2.3