Skip to content

Commit

Permalink
Merge pull request #5 from pmamatsis/master
Browse files Browse the repository at this point in the history
Boid Desktop various stability issues
  • Loading branch information
boid-com committed Aug 18, 2019
2 parents 14c9cbe + ccf3523 commit 769f7b2
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 23 deletions.
48 changes: 36 additions & 12 deletions src/appWindow.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,47 @@
/*
* Main window event and additional javascript
*/
const webview = document.getElementById('webview')
const msg = document.getElementById('loadingmsg')
var initial = true

/*
* Event Description: Fired when document in the given frame is loaded.
*/
webview.addEventListener('dom-ready', () => {
// webview.openDevTools()
//webview.openDevTools() //<--- This line must be commented out before commit to git.
if(!initial) return
initial = false
webview.setZoomLevel(0)
})

webview.addEventListener('did-fail-load', (e, string) => {
console.log('Failed to load')
msg.style.display = "block"
setTimeout(() => {
webview.reload()
}, 13000)
})
webview.addEventListener('page-title-updated', (e) => {
msg.style.display = "none"
console.log(e)
})
const failToLoadPage = (e, string) => {
console.log('Failed to load')
msg.style.display = "block"
setTimeout(() => {
webview.reload()
}, 13000)
}

/*
* Event Description: This event is like did-finish-load, but fired when the load failed or was cancelled, e.g. window.stop() is invoked.
*/
webview.addEventListener('did-fail-load', failToLoadPage) //<--- Converted to a lambda in order to be used during the 'removeEventListener' call.

/*
* Fired when page title is set during navigation.
*/
webview.addEventListener('page-title-updated', (e) => {
msg.style.display = "none"
console.log(e)
})

/*
* Event Description: Fired when a load has committed. This includes navigation within the current document as well as subframe document-level loads, but does not include asynchronous resource loads.
*
* NOTE: This event is been used in order to cancel the reload of the server page.
*/
webview.addEventListener('load-commit', (e) => {
console.log('Finished the loading process')
webview.removeEventListener('did-fail-load', failToLoadPage)
})
23 changes: 13 additions & 10 deletions src/boinc.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,16 +146,19 @@ boinc.start = async (data) => {
boinc.process.on('exit', (code, signal) => {
log.info('detected close code:', code, signal)
log.info('should be running', boinc.shouldBeRunning)
boinc.process.removeAllListeners()
boinc.process = null
if(boinc.shouldBeRunning) {
boinc.send('message', 'The Miner stopped and Boid is restarting it')
boinc.start()
} else {
boinc.send('message', 'BOINC was stopped')
boinc.send('status', 'Stopped')
boinc.send('toggle', false)
cfg.set('state.cpu.toggle', false)
//Check if the 'process' is a valid object.
if(boinc.process){
boinc.process.removeAllListeners()
boinc.process = null
if(boinc.shouldBeRunning) {
boinc.send('message', 'The Miner stopped and Boid is restarting it')
boinc.start()
} else {
boinc.send('message', 'BOINC was stopped')
boinc.send('status', 'Stopped')
boinc.send('toggle', false)
cfg.set('state.cpu.toggle', false)
}
}
})
}catch(error){if(ec)ec(error)}
Expand Down
2 changes: 1 addition & 1 deletion src/registerGlobalListeners.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function init(appWindow) {
app.on('before-quit', async ()=>{
isQuiting = true
if (appWindow) appWindow.close()
await boinc.killExisting()
if(boinc.process) await boinc.killExisting() //<--- We must check if the 'process' is active prior killing it. If not, we get errors in console.
})
app.on('activate', () => appWindow.show)
appWindow.on('ready-to-show', () => {
Expand Down

0 comments on commit 769f7b2

Please sign in to comment.