aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/scripts/lib/notifications.js30
1 files changed, 19 insertions, 11 deletions
diff --git a/app/scripts/lib/notifications.js b/app/scripts/lib/notifications.js
index 432ad0445..87d758e3b 100644
--- a/app/scripts/lib/notifications.js
+++ b/app/scripts/lib/notifications.js
@@ -9,11 +9,12 @@ module.exports = notifications
window.METAMASK_NOTIFIER = notifications
function show () {
- getPopup((popup) => {
- if (popup) {
- return extension.windows.update(popup.id, { focused: true })
- }
+ getWindows((windows) => {
+ if (windows.length > 0) {
+ const win = windows[0]
+ return extension.windows.update(win.id, { focused: true })
+ }
extension.windows.create({
url: 'notification.html',
@@ -25,22 +26,29 @@ function show () {
})
}
-function getPopup(cb) {
-
+function getWindows(cb) {
// Ignore in test environment
if (!extension.windows) {
- return cb(null)
+ return cb()
}
extension.windows.getAll({}, (windows) => {
- let popup = windows.find((win) => {
- return win.type === 'popup'
- })
+ cb(null, windows)
+ })
+}
- cb(popup)
+function getPopup(cb) {
+ getWindows((windows) => {
+ cb(getPopupIn(windows))
})
}
+function getPopupIn(windows) {
+ return windows ? windows.find((win) => {
+ return win.type === 'popup'
+ }) : null
+}
+
function closePopup() {
getPopup((popup) => {
if (!popup) return