diff options
author | Jeffrey Tong <trigun0x2@gmail.com> | 2018-03-12 01:17:08 +0800 |
---|---|---|
committer | Jeffrey Tong <trigun0x2@gmail.com> | 2018-03-12 01:17:08 +0800 |
commit | bda493dc9dc7436e5169a3344d8a72eb3c8d48d8 (patch) | |
tree | 648fde9c7c9842f5b5980778c2101cfd041e848d | |
parent | aaef2aeefde39ce11ef07603fd1cb5d2cbb1e294 (diff) | |
download | tangerine-wallet-browser-bda493dc9dc7436e5169a3344d8a72eb3c8d48d8.tar.gz tangerine-wallet-browser-bda493dc9dc7436e5169a3344d8a72eb3c8d48d8.tar.zst tangerine-wallet-browser-bda493dc9dc7436e5169a3344d8a72eb3c8d48d8.zip |
add comments that need clarification on naming convention
-rw-r--r-- | app/scripts/background.js | 4 | ||||
-rw-r--r-- | app/scripts/lib/notification-manager.js | 14 | ||||
-rw-r--r-- | 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() } } |