aboutsummaryrefslogtreecommitdiffstats
path: root/library/sw-controller.js
diff options
context:
space:
mode:
authorfrankiebee <frankie.diamond@gmail.com>2017-03-29 09:02:08 +0800
committerfrankiebee <frankie.diamond@gmail.com>2017-03-29 09:02:08 +0800
commit79248ae5cd3fb1314c5a7ff71c05f9dbe7b3a4cd (patch)
tree5b08ce8a990ae2b33ff7d5a81b17fcfe0130a658 /library/sw-controller.js
parent282775c52f558bbd90d4d0a1706a835dde6c3202 (diff)
downloadtangerine-wallet-browser-79248ae5cd3fb1314c5a7ff71c05f9dbe7b3a4cd.tar.gz
tangerine-wallet-browser-79248ae5cd3fb1314c5a7ff71c05f9dbe7b3a4cd.tar.zst
tangerine-wallet-browser-79248ae5cd3fb1314c5a7ff71c05f9dbe7b3a4cd.zip
WIP: Untrusted external connections eg: dapps
Diffstat (limited to 'library/sw-controller.js')
-rw-r--r--library/sw-controller.js20
1 files changed, 3 insertions, 17 deletions
diff --git a/library/sw-controller.js b/library/sw-controller.js
index 23d67026e..1a7b1cad3 100644
--- a/library/sw-controller.js
+++ b/library/sw-controller.js
@@ -7,22 +7,10 @@ module.exports = class ClientSideServiceWorker extends EventEmitter{
this.startDelay = opts.startDelay
this.serviceWorkerApi = navigator.serviceWorker
- this.serviceWorkerApi.onmessage = (event) => this.emit('message', event)
- this.serviceWorkerApi.onerror = (event) => this.emit('error')
-
- // temporary function
- this.askForId = (message) => {
- this.sendMessage('check-in')
- .then((data) => console.log(`${message}----${data}`))
- }
-
- // if (!!this.serviceWorkerApi) this.askForId('before')
-
+ this.serviceWorkerApi.onmessage = (messageEvent) => this.emit('message', messageEvent)
+ this.serviceWorkerApi.onerror = (err) => this.emit('error', err)
+ this.on('message', (messageEvent) => {debugger})
if (opts.initStart) this.startWorker()
-
- this.on('ready', (sw) => {
- this.askForId('ready')
- })
}
get controller () {
@@ -34,7 +22,6 @@ module.exports = class ClientSideServiceWorker extends EventEmitter{
return this.registerWorker()
.then((sw) => {
this.sw = sw
- this.askForId('after register:')
this.sw.onerror = (err) => this.emit('error', err)
this.sw = sw
this.emit('ready', this.sw)
@@ -46,7 +33,6 @@ module.exports = class ClientSideServiceWorker extends EventEmitter{
return this.serviceWorkerApi.register(this.fileName)
.then((registerdWorker) => {
return new Promise((resolve, reject) => {
- this.askForId('after')
let timeOutId = setTimeout(() => {
if (this.serviceWorkerApi.controller) return resolve(this.serviceWorkerApi.controller)
if (registerdWorker.active) return resolve(registerdWorker.active)