1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-26 12:29:06 +01:00

dont reload on initial download and wait before passing sw to ui

This commit is contained in:
frankiebee 2017-09-15 11:09:19 -07:00
parent b53d04c409
commit 7fb8623568
3 changed files with 28 additions and 18 deletions

View File

@ -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)
})
}

View File

@ -1,6 +1,5 @@
const Helper = require('./util/mascara-test-helper.js')
window.METAMASK_SKIP_RELOAD = true
window.addEventListener('load', () => {
// inject app container
const body = document.body

View File

@ -12,7 +12,7 @@ QUnit.test('render init screen', (assert) => {
async function runFirstTimeUsageTest(assert, done) {
await timeout()
await timeout(10000)
const app = $('#app-content')
@ -123,7 +123,7 @@ async function runFirstTimeUsageTest(assert, done) {
assert.ok(children2, 'All network options present')
}
function timeout(time) {
function timeout (time) {
return new Promise(function (resolve, reject) {
setTimeout(function () {
resolve()