1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00

add comments that need clarification on naming convention

This commit is contained in:
Jeffrey Tong 2018-03-11 10:17:08 -07:00
parent aaef2aeefd
commit bda493dc9d
3 changed files with 10 additions and 9 deletions

View File

@ -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;
})
}

View File

@ -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
}

View File

@ -65,6 +65,7 @@ startPopup({ container, connectionStream }, (err, store) => {
function closePopupIfOpen (windowType) {
if (windowType !== 'notification') {
// should close only chrome popup
notificationManager.closePopup()
}
}