aboutsummaryrefslogtreecommitdiffstats
path: root/mascara/src/ui.js
diff options
context:
space:
mode:
Diffstat (limited to 'mascara/src/ui.js')
-rw-r--r--mascara/src/ui.js20
1 files changed, 18 insertions, 2 deletions
diff --git a/mascara/src/ui.js b/mascara/src/ui.js
index cdf985ebd..07763cc5e 100644
--- a/mascara/src/ui.js
+++ b/mascara/src/ui.js
@@ -27,7 +27,7 @@ const background = new SWcontroller({
wakeUpInterval: 20000
})
// Setup listener for when the service worker is read
-background.on('ready', (readSw) => {
+const connectApp = function (readSw) {
let connectionStream = SwStream({
serviceWorker: background.controller,
context: name,
@@ -37,8 +37,24 @@ background.on('ready', (readSw) => {
store.subscribe(() => {
const state = store.getState()
if (state.appState.shouldClose) window.close()
+ console.log('IN the things?')
})
})
+}
+
+background.on('ready', (sw) => {
+ background.removeListener('updatefound', connectApp)
+ connectApp(sw)
+})
+background.on('updatefound', () => background.serviceWorkerApi.ready
+ .then((sw) =>{
+ background.removeListener('ready', connectApp)
+ connectApp(sw.active)
+ })
+)
+background.on('message', (messageEvent) => {
+ console.log(messageEvent)
})
-background.startWorker()
+window.addEventListener('load', () => background.startWorker())
+// background.startWorker()
console.log('hello from MetaMascara ui!')