diff options
Diffstat (limited to 'app/scripts/popup.js')
-rw-r--r-- | app/scripts/popup.js | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/app/scripts/popup.js b/app/scripts/popup.js index 20be15df7..096b56115 100644 --- a/app/scripts/popup.js +++ b/app/scripts/popup.js @@ -9,7 +9,9 @@ const injectCss = require('inject-css') const PortStream = require('./lib/port-stream.js') 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() @@ -22,7 +24,11 @@ async.parallel({ function connectToAccountManager (cb) { // setup communication with background - var pluginPort = extension.runtime.connect({name: 'popup'}) + + var name = isPopupOrNotification() + closePopupIfOpen(name) + window.METAMASK_UI_TYPE = name + var pluginPort = extension.runtime.connect({ name }) var portStream = new PortStream(pluginPort) // setup multiplexing var mx = setupMultiplex(portStream) @@ -68,22 +74,12 @@ function getCurrentDomain (cb) { }) } -function clearNotifications(){ - extension.notifications.getAll(function (object) { - for (let notification in object){ - extension.notifications.clear(notification) - } - }) -} - function setupApp (err, opts) { if (err) { alert(err.stack) throw err } - clearNotifications() - var container = document.getElementById('app-content') MetaMaskUi({ @@ -93,3 +89,9 @@ function setupApp (err, opts) { networkVersion: opts.networkVersion, }) } + +function closePopupIfOpen(name) { + if (name !== 'notification') { + notification.closePopup() + } +} |