aboutsummaryrefslogtreecommitdiffstats
path: root/library/src/popup.js
diff options
context:
space:
mode:
authorfrankiebee <frankie.diamond@gmail.com>2017-04-03 17:03:58 +0800
committerfrankiebee <frankie.diamond@gmail.com>2017-04-03 17:03:58 +0800
commit12065a10aab05690b45c83648ee26f85f403b864 (patch)
tree9894727894385c681435e6f35345f5fe419da537 /library/src/popup.js
parentf81fdbc34ff037ab64a9f4c98100304e7b1132e4 (diff)
downloadtangerine-wallet-browser-12065a10aab05690b45c83648ee26f85f403b864.tar
tangerine-wallet-browser-12065a10aab05690b45c83648ee26f85f403b864.tar.gz
tangerine-wallet-browser-12065a10aab05690b45c83648ee26f85f403b864.tar.bz2
tangerine-wallet-browser-12065a10aab05690b45c83648ee26f85f403b864.tar.lz
tangerine-wallet-browser-12065a10aab05690b45c83648ee26f85f403b864.tar.xz
tangerine-wallet-browser-12065a10aab05690b45c83648ee26f85f403b864.tar.zst
tangerine-wallet-browser-12065a10aab05690b45c83648ee26f85f403b864.zip
Make Popup close after approving a transaction
Diffstat (limited to 'library/src/popup.js')
-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()