cleanup app comments

This commit is contained in:
jobevers 2017-02-23 12:46:25 -06:00
parent 6b7dca8bb1
commit 8a42412096

View file

@ -1,15 +1,12 @@
const {app, BrowserWindow, ipcMain} = require('electron');
var path = require('path');
var jayson = require('jayson');
const path = require('path');
const jayson = require('jayson');
// tree-kill has better cross-platform handling of
// killing a process. child-process.kill was unreliable
var kill = require('tree-kill');
const kill = require('tree-kill');
let client = jayson.client.http('http://localhost:5279/lbryapi');
// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected.
let win
@ -20,21 +17,14 @@ let quitting = false;
function createWindow () {
// Create the browser window.
//win = new BrowserWindow({x: 0, y: 0, width: 1440, height: 414, backgroundColor: '#155b4a'})
win = new BrowserWindow({backgroundColor: '#155b4a'})
win.maximize()
//win.webContents.openDevTools()
// and load the index.html of the app.
win.loadURL(`file://${__dirname}/dist/index.html`)
// Emitted when the window is closed.
win.on('closed', () => {
// Dereference the window object, usually you would store windows
// in an array if your app supports multi windows, this is the time
// when you should delete the corresponding element.
win = null
})
};
@ -55,8 +45,13 @@ function lauchDaemon() {
console.log('The daemon has exited. Quitting the app');
subpy = null;
if (quitting) {
// If quitting is True it means that we were expecting the daemon
// to be shutdown so we can quit right away
app.quit();
} else {
// Otherwise, this shutdown was a surprise so display a warning
// and schedule a quit
//
// TODO: maybe it would be better to restart the daemon?
win.loadURL(`file://${__dirname}/dist/warning.html`);
setTimeout(app.quit, 5000)
@ -65,13 +60,17 @@ function lauchDaemon() {
console.log('lbrynet daemon has launched')
}
// This method will be called when Electron has finished
// initialization and is ready to create browser windows.
// Some APIs can only be used after this event occurs.
app.on('ready', function(){
launchDaemonIfNotRunning();
createWindow();
});
function launchDaemonIfNotRunning() {
// Check if the daemon is already running. If we get
// an error its because its not running
console.log('Checking for lbrynet daemon')
console.log('Checking for lbrynet daemon');
client.request(
'status', [],
function (err, res) {
@ -83,8 +82,7 @@ app.on('ready', function(){
}
}
);
createWindow();
});
}
// Quit when all windows are closed.
@ -96,6 +94,7 @@ app.on('window-all-closed', () => {
}
})
app.on('before-quit', (event) => {
if (subpy == null) {
return