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

feature/default_network_editable
frankiebee 7 years ago
parent b53d04c409
commit 7fb8623568
  1. 41
      mascara/src/ui.js
  2. 1
      mascara/test/test-ui.js
  3. 4
      test/integration/lib/first-time.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)
})
}

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

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

Loading…
Cancel
Save