diff options
author | frankiebee <frankie.diamond@gmail.com> | 2017-09-16 02:09:19 +0800 |
---|---|---|
committer | frankiebee <frankie.diamond@gmail.com> | 2017-09-16 02:09:19 +0800 |
commit | 7fb862356873fc4c5dc28e5c7389f71424985b0f (patch) | |
tree | f9d9cb8a2eb2d23e0dd93d710203c746aa55c880 /mascara/src | |
parent | b53d04c40975adc0fadf20bc6ca875bd9c39e595 (diff) | |
download | tangerine-wallet-browser-7fb862356873fc4c5dc28e5c7389f71424985b0f.tar tangerine-wallet-browser-7fb862356873fc4c5dc28e5c7389f71424985b0f.tar.gz tangerine-wallet-browser-7fb862356873fc4c5dc28e5c7389f71424985b0f.tar.bz2 tangerine-wallet-browser-7fb862356873fc4c5dc28e5c7389f71424985b0f.tar.lz tangerine-wallet-browser-7fb862356873fc4c5dc28e5c7389f71424985b0f.tar.xz tangerine-wallet-browser-7fb862356873fc4c5dc28e5c7389f71424985b0f.tar.zst tangerine-wallet-browser-7fb862356873fc4c5dc28e5c7389f71424985b0f.zip |
dont reload on initial download and wait before passing sw to ui
Diffstat (limited to 'mascara/src')
-rw-r--r-- | mascara/src/ui.js | 41 |
1 files changed, 26 insertions, 15 deletions
diff --git a/mascara/src/ui.js b/mascara/src/ui.js index 7506532d2..05521d095 100644 --- a/mascara/src/ui.js +++ b/mascara/src/ui.js @@ -30,30 +30,41 @@ const connectApp = function (readSw) { 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() + return new Promise((resolve, reject) => { + startPopup({ container, connectionStream }, (err, store) => { + console.log('hello from MetaMascara ui!') + if (err) reject(err) + store.subscribe(() => { + const state = store.getState() + if (state.appState.shouldClose) window.close() + }) + resolve() }) }) } -background.on('ready', (sw) => { - background.removeListener('updatefound', connectApp) - connectApp(sw) +background.on('ready', async (sw) => { + try { + background.removeListener('updatefound', connectApp) + await timeout(1000) + await connectApp(sw) + console.log('hello from cb ready event!') + } catch (e) { + console.error(e) + } }) background.on('updatefound', windowReload) background.startWorker() -.then(() => { - setTimeout(() => { - const container = document.getElementById(`app-content`) - if (!container.children.length) windowReload() - }, 2000) -}) -console.log('hello from MetaMascara ui!') function windowReload() { if (window.METAMASK_SKIP_RELOAD) return window.location.reload() } + +function timeout (time) { + return new Promise(function (resolve, reject) { + setTimeout(function () { + resolve() + }, time || 1500) + }) +}
\ No newline at end of file |