From f663692b71e4bcc7ad565e13e7c949efb52ad89e Mon Sep 17 00:00:00 2001 From: Panagiotis Mamatsis Date: Sun, 4 Aug 2019 14:02:22 +0300 Subject: [PATCH 1/5] Test Commit This is a test commit message. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 3c58968..095725c 100644 --- a/package.json +++ b/package.json @@ -1,4 +1,4 @@ -{ + { "name": "boid", "productName": "Boid", "version": "0.0.51", From a7817c071805d3c730ceb76a68c15a716974a9a8 Mon Sep 17 00:00:00 2001 From: Panagiotis Mamatsis Date: Sun, 4 Aug 2019 14:05:18 +0300 Subject: [PATCH 2/5] Revert back Revert back --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 095725c..3c58968 100644 --- a/package.json +++ b/package.json @@ -1,4 +1,4 @@ - { +{ "name": "boid", "productName": "Boid", "version": "0.0.51", From 13025e381633c2106033bc15ef32f2e55af608d0 Mon Sep 17 00:00:00 2001 From: Panagiotis Mamatsis Date: Sat, 10 Aug 2019 18:29:49 +0300 Subject: [PATCH 3/5] Stability of BoidDesktop When quiting the application it must quit "gracefully" ie. no errors in the console. - Added one extra "if" statement in "registerGlobalListeners.js" script in line 18, for electronjs event "before-quit". - Added one extra "if" statement in "boinc.js" script in line 149, for boinc.process object event "exit". --- src/boinc.js | 22 ++++++++++++---------- src/registerGlobalListeners.js | 2 +- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/boinc.js b/src/boinc.js index 4c37839..c07b4d0 100644 --- a/src/boinc.js +++ b/src/boinc.js @@ -146,16 +146,18 @@ 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) + 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)} diff --git a/src/registerGlobalListeners.js b/src/registerGlobalListeners.js index d1f7ada..75d1cef 100644 --- a/src/registerGlobalListeners.js +++ b/src/registerGlobalListeners.js @@ -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() }) app.on('activate', () => appWindow.show) appWindow.on('ready-to-show', () => { From a5645e553da9debfb56be2c2d65880d1af542ce3 Mon Sep 17 00:00:00 2001 From: Panagiotis Mamatsis Date: Fri, 16 Aug 2019 21:50:17 +0300 Subject: [PATCH 4/5] Clean up code --- src/boinc.js | 1 + src/registerGlobalListeners.js | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/boinc.js b/src/boinc.js index c07b4d0..465bdc4 100644 --- a/src/boinc.js +++ b/src/boinc.js @@ -146,6 +146,7 @@ boinc.start = async (data) => { boinc.process.on('exit', (code, signal) => { log.info('detected close code:', code, signal) log.info('should be running', boinc.shouldBeRunning) + //Check if the 'process' is a valid object. if(boinc.process){ boinc.process.removeAllListeners() boinc.process = null diff --git a/src/registerGlobalListeners.js b/src/registerGlobalListeners.js index 75d1cef..f9760fc 100644 --- a/src/registerGlobalListeners.js +++ b/src/registerGlobalListeners.js @@ -15,7 +15,7 @@ function init(appWindow) { app.on('before-quit', async ()=>{ isQuiting = true if (appWindow) appWindow.close() - if(boinc.process) 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', () => { From ccf352339aae8074a4eda0a88dac8f6db3d0d4f7 Mon Sep 17 00:00:00 2001 From: Panagiotis Mamatsis Date: Sat, 17 Aug 2019 21:02:28 +0300 Subject: [PATCH 5/5] Fixed the auto-reload issue for the server-side code. --- src/appWindow.js | 48 ++++++++++++++++++++++++++++++++++++------------ 1 file changed, 36 insertions(+), 12 deletions(-) diff --git a/src/appWindow.js b/src/appWindow.js index f115587..7a755cc 100644 --- a/src/appWindow.js +++ b/src/appWindow.js @@ -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) }) \ No newline at end of file