From 36bafbaebf826933262c4ad381a8953e82f8ebc3 Mon Sep 17 00:00:00 2001 From: frankiebee Date: Fri, 28 Apr 2017 14:05:10 +0200 Subject: [PATCH] General cleanup and window reload if an update is found --- mascara/README.md | 12 ++++++++++++ mascara/src/background.js | 3 +-- mascara/src/proxy.js | 1 + mascara/src/ui.js | 13 +++---------- 4 files changed, 17 insertions(+), 12 deletions(-) diff --git a/mascara/README.md b/mascara/README.md index 75d3cabad..db5b4f404 100644 --- a/mascara/README.md +++ b/mascara/README.md @@ -10,3 +10,15 @@ npm run mascara - go back to http://localhost:9002 - open devTools - click Sync Tx + +## Tests: + +``` +npm run testMascara +``` + +Test will run in browser, you will have to have these browsers installed: + +- Chrome +- Firefox +- Opera diff --git a/mascara/src/background.js b/mascara/src/background.js index a6703b291..dff5e6a7c 100644 --- a/mascara/src/background.js +++ b/mascara/src/background.js @@ -7,7 +7,7 @@ const connectionListener = new SwGlobalListener(self) const setupMultiplex = require('../../app/scripts/lib/stream-utils.js').setupMultiplex const PortStream = require('../../app/scripts/lib/port-stream.js') -const DbController = require('./lib/index-db-controller') +const DbController = require('idb-global') const SwPlatform = require('../../app/scripts/platforms/sw') const MetamaskController = require('../../app/scripts/metamask-controller') @@ -47,7 +47,6 @@ console.log('inside:open') let diskStore const dbController = new DbController({ key: STORAGE_KEY, - version: 2, }) loadStateFromPersistence() .then((initState) => setupController(initState)) diff --git a/mascara/src/proxy.js b/mascara/src/proxy.js index ec5665240..eabc547b4 100644 --- a/mascara/src/proxy.js +++ b/mascara/src/proxy.js @@ -20,6 +20,7 @@ background.on('ready', (_) => { pageStream.pipe(swStream).pipe(pageStream) }) +background.on('updatefound', () => window.location.reload()) background.on('error', console.error) background.startWorker() diff --git a/mascara/src/ui.js b/mascara/src/ui.js index 07763cc5e..65a55ccc3 100644 --- a/mascara/src/ui.js +++ b/mascara/src/ui.js @@ -46,15 +46,8 @@ 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) -}) -window.addEventListener('load', () => background.startWorker()) +background.on('updatefound', () => window.location.reload()) + +background.startWorker() // background.startWorker() console.log('hello from MetaMascara ui!')