aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--library/src/popup.js21
1 files changed, 14 insertions, 7 deletions
diff --git a/library/src/popup.js b/library/src/popup.js
index 3dcc508bf..ef7759a81 100644
--- a/library/src/popup.js
+++ b/library/src/popup.js
@@ -1,28 +1,35 @@
const injectCss = require('inject-css')
+const SWcontroller = require('client-sw-ready-event/lib/sw-client.js')
+const SwStream = require('sw-stream/lib/sw-stream.js')
const MetaMaskUiCss = require('../../ui/css')
const setupIframe = require('./lib/setup-iframe.js')
const MetamaskInpageProvider = require('../../app/scripts/lib/inpage-provider.js')
-const SWcontroller = require('client-sw-ready-event/lib/sw-client.js')
-const SwStream = require('sw-stream/lib/sw-stream.js')
const startPopup = require('../../app/scripts/popup-core')
-
var css = MetaMaskUiCss()
injectCss(css)
+const container = document.getElementById('app-content')
var name = 'popup'
window.METAMASK_UI_TYPE = name
-console.log('outside:open')
-
const background = new SWcontroller({
fileName: '/popup/sw-build.js',
})
+
+// Setup listener for when the service worker is read
background.on('ready', (readSw) => {
- let swStream = SwStream({
+ let connectionStream = SwStream({
serviceWorker: background.controller,
+ context: name,
+ })
+ startPopup({container, connectionStream}, (err, store) => {
+ if (err) return displayCriticalError(err)
+ store.subscribe(() => {
+ const state = store.getState()
+ if (state.appState.shouldClose) window.close()
+ })
})
- startPopup(swStream)
})
background.startWorker()