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:
parent
aaef2aeefd
commit
bda493dc9d
@ -184,9 +184,7 @@ function setupController (initState) {
|
|||||||
function triggerUi () {
|
function triggerUi () {
|
||||||
extension.tabs.query({ active: true }, (tabs) => {
|
extension.tabs.query({ active: true }, (tabs) => {
|
||||||
const currentlyActiveMetamaskTab = tabs.find(tab => openMetamaskTabsIDs[tab.id])
|
const currentlyActiveMetamaskTab = tabs.find(tab => openMetamaskTabsIDs[tab.id])
|
||||||
if (!popupIsOpen && !currentlyActiveMetamaskTab) notificationManager.showPopup((notification) => {
|
if (!popupIsOpen && !currentlyActiveMetamaskTab) notificationManager.showPopup();
|
||||||
notifcationIsOpen = notification;
|
|
||||||
});
|
|
||||||
notifcationIsOpen = true;
|
notifcationIsOpen = true;
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -9,29 +9,28 @@ class NotificationManager {
|
|||||||
// Public
|
// Public
|
||||||
//
|
//
|
||||||
|
|
||||||
showPopup (cb) {
|
showPopup () {
|
||||||
this._getPopup((err, popup) => {
|
this._getPopup((err, popup) => {
|
||||||
if (err) throw err
|
if (err) throw err
|
||||||
|
|
||||||
|
// Bring focus to chrome popup
|
||||||
if (popup) {
|
if (popup) {
|
||||||
// bring focus to existing popup
|
// bring focus to existing chrome popup
|
||||||
extension.windows.update(popup.id, { focused: true })
|
extension.windows.update(popup.id, { focused: true })
|
||||||
} else {
|
} else {
|
||||||
// create new popup
|
// create new notification popup
|
||||||
extension.windows.create({
|
extension.windows.create({
|
||||||
url: 'notification.html',
|
url: 'notification.html',
|
||||||
type: 'popup',
|
type: 'popup',
|
||||||
width,
|
width,
|
||||||
height,
|
height,
|
||||||
}, (win) => {
|
|
||||||
// naming of popup window and a popup in chrome extension sense is confusing
|
|
||||||
cb((win.type == 'popup'));
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
closePopup () {
|
closePopup () {
|
||||||
|
// closes notification popup
|
||||||
this._getPopup((err, popup) => {
|
this._getPopup((err, popup) => {
|
||||||
if (err) throw err
|
if (err) throw err
|
||||||
if (!popup) return
|
if (!popup) return
|
||||||
@ -46,6 +45,7 @@ class NotificationManager {
|
|||||||
_getPopup (cb) {
|
_getPopup (cb) {
|
||||||
this._getWindows((err, windows) => {
|
this._getWindows((err, windows) => {
|
||||||
if (err) throw err
|
if (err) throw err
|
||||||
|
console.log(windows);
|
||||||
cb(null, this._getPopupIn(windows))
|
cb(null, this._getPopupIn(windows))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -63,6 +63,8 @@ class NotificationManager {
|
|||||||
|
|
||||||
_getPopupIn (windows) {
|
_getPopupIn (windows) {
|
||||||
return windows ? windows.find((win) => {
|
return windows ? windows.find((win) => {
|
||||||
|
// Returns notification popup
|
||||||
|
console.log(win);
|
||||||
return (win && win.type === 'popup')
|
return (win && win.type === 'popup')
|
||||||
}) : null
|
}) : null
|
||||||
}
|
}
|
||||||
|
@ -65,6 +65,7 @@ startPopup({ container, connectionStream }, (err, store) => {
|
|||||||
|
|
||||||
function closePopupIfOpen (windowType) {
|
function closePopupIfOpen (windowType) {
|
||||||
if (windowType !== 'notification') {
|
if (windowType !== 'notification') {
|
||||||
|
// should close only chrome popup
|
||||||
notificationManager.closePopup()
|
notificationManager.closePopup()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user