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