diff options
-rw-r--r-- | app/scripts/lib/notifications.js | 11 | ||||
-rw-r--r-- | app/scripts/popup.js | 7 | ||||
-rw-r--r-- | ui/app/reducers/app.js | 8 |
3 files changed, 17 insertions, 9 deletions
diff --git a/app/scripts/lib/notifications.js b/app/scripts/lib/notifications.js index c8ecad805..dcb946845 100644 --- a/app/scripts/lib/notifications.js +++ b/app/scripts/lib/notifications.js @@ -1,13 +1,14 @@ const extension = require('./extension') const notifications = { - show: showNotification, + show, getPopup, + closePopup, } module.exports = notifications window.METAMASK_NOTIFIER = notifications -function showNotification() { +function show () { getPopup((popup) => { if (popup) { return extension.windows.update(popup.id, { focused: true }) @@ -39,3 +40,9 @@ function getPopup(cb) { }) } +function closePopup() { + getPopup((popup) => { + if (!popup) return + extension.windows.remove(popup.id, console.error) + }) +} diff --git a/app/scripts/popup.js b/app/scripts/popup.js index 4c729e227..90b90a7af 100644 --- a/app/scripts/popup.js +++ b/app/scripts/popup.js @@ -11,6 +11,7 @@ const StreamProvider = require('web3-stream-provider') const setupMultiplex = require('./lib/stream-utils.js').setupMultiplex const isPopupOrNotification = require('./lib/is-popup-or-notification') const extension = require('./lib/extension') +const notification = require('./lib/notifications') // setup app var css = MetaMaskUiCss() @@ -25,6 +26,7 @@ function connectToAccountManager (cb) { // setup communication with background var name = isPopupOrNotification() + closePopupIfOpen(name) window.METAMASK_UI_TYPE = name var pluginPort = extension.runtime.connect({ name }) var portStream = new PortStream(pluginPort) @@ -98,3 +100,8 @@ function setupApp (err, opts) { }) } +function closePopupIfOpen(name) { + if (name !== 'notification') { + notification.closePopup() + } +} diff --git a/ui/app/reducers/app.js b/ui/app/reducers/app.js index 7bd1dfd1f..132e73f69 100644 --- a/ui/app/reducers/app.js +++ b/ui/app/reducers/app.js @@ -253,7 +253,7 @@ function reduceApp (state, action) { }) } else { - closePopupIfOpen() + notification.closePopup() return extend(appState, { transForward: false, @@ -520,9 +520,3 @@ function indexForPending (state, txId) { return idx } -function closePopupIfOpen() { - notification.getPopup((popup) => { - if (!popup) return - extension.windows.remove(popup.id, console.error) - }) -} |