Better IPC naming

This commit is contained in:
Jeffrey Morgan 2015-03-08 18:31:28 -04:00
parent b36388f6eb
commit 2994b23825
3 changed files with 16 additions and 20 deletions

View File

@ -37,12 +37,10 @@ var Containers = React.createClass({
this.transitionTo('containerHome', {name: this.state.sorted[0].Name}); this.transitionTo('containerHome', {name: this.state.sorted[0].Name});
} }
ipc.on('notify', message => { ipc.on('application:update-available', () => {
if (message === 'application:update-available') { this.setState({
this.setState({ updateAvailable: true
updateAvailable: true });
});
}
}); });
autoUpdater.checkForUpdates(); autoUpdater.checkForUpdates();
}, },
@ -102,7 +100,7 @@ var Containers = React.createClass({
}, },
handleAutoUpdateClick: function () { handleAutoUpdateClick: function () {
metrics.track('Restarted to Update'); metrics.track('Restarted to Update');
ipc.send('command', 'application:quit-install'); ipc.send('application:quit-install');
}, },
handleClickPreferences: function () { handleClickPreferences: function () {
metrics.track('Opened Preferences', { metrics.track('Opened Preferences', {

View File

@ -76,8 +76,8 @@ document.onkeydown = function (e) {
} }
}; };
ipc.on('notify', msg => { ipc.on('application:quitting', () => {
if (msg === 'application:quitting' && localStorage.getItem('settings.closeVMOnQuit') === 'true') { if (localStorage.getItem('settings.closeVMOnQuit') === 'true') {
machine.stop(); machine.stop();
} }
}); });

View File

@ -5,21 +5,20 @@ var fs = require('fs');
var ipc = require('ipc'); var ipc = require('ipc');
var path = require('path'); var path = require('path');
process.env.NODE_PATH = __dirname + '/../node_modules'; process.env.NODE_PATH = path.join(__dirname, '/../node_modules');
process.env.RESOURCES_PATH = __dirname + '/../resources'; process.env.RESOURCES_PATH = path.join(__dirname, '/../resources');
process.chdir(path.join(__dirname, '..')); process.chdir(path.join(__dirname, '..'));
process.env.PATH = '/usr/local/bin:' + process.env.PATH; process.env.PATH = '/usr/local/bin:' + process.env.PATH;
var size = {}, settingsjson = {}; var size = {}, settingsjson = {};
try { try {
var sizeFile = JSON.parse(fs.readFileSync(path.join(process.env[(process.platform === 'win32') ? 'USERPROFILE' : 'HOME'], 'Library', 'Application\ Support', 'Kitematic', 'size'))); size = JSON.parse(fs.readFileSync(path.join(process.env[(process.platform === 'win32') ? 'USERPROFILE' : 'HOME'], 'Library', 'Application\ Support', 'Kitematic', 'size')));
size = sizeFile;
} catch (err) {} } catch (err) {}
try { try {
settingsjson = JSON.parse(fs.readFileSync(path.join(__dirname, '..', 'settings.json'), 'utf8')); settingsjson = JSON.parse(fs.readFileSync(path.join(__dirname, '..', 'settings.json'), 'utf8'));
} catch (err) {} } catch (err) {}
app.on('ready', function() { app.on('ready', function () {
var mainWindow = new BrowserWindow({ var mainWindow = new BrowserWindow({
width: size.width || 1000, width: size.width || 1000,
height: size.height || 700, height: size.height || 700,
@ -29,6 +28,7 @@ app.on('ready', function() {
frame: false, frame: false,
show: true show: true
}); });
mainWindow.loadUrl(path.normalize('file://' + path.join(__dirname, '..', 'build/index.html'))); mainWindow.loadUrl(path.normalize('file://' + path.join(__dirname, '..', 'build/index.html')));
app.on('activate-with-no-open-windows', function () { app.on('activate-with-no-open-windows', function () {
@ -39,13 +39,11 @@ app.on('ready', function() {
}); });
app.on('before-quit', function () { app.on('before-quit', function () {
mainWindow.webContents.send('notify', 'application:quitting'); mainWindow.webContents.send('application:quitting');
}); });
ipc.on('command', function (event, arg) { ipc.on('application:quit-install', function () {
if (arg === 'application:quit-install') { autoUpdater.quitAndInstall();
autoUpdater.quitAndInstall();
}
}); });
mainWindow.webContents.on('new-window', function (e) { mainWindow.webContents.on('new-window', function (e) {
@ -83,7 +81,7 @@ app.on('ready', function() {
autoUpdater.on('update-downloaded', function (e, releaseNotes, releaseName, releaseDate, updateURL) { autoUpdater.on('update-downloaded', function (e, releaseNotes, releaseName, releaseDate, updateURL) {
console.log('Update downloaded.'); console.log('Update downloaded.');
console.log(releaseNotes, releaseName, releaseDate, updateURL); console.log(releaseNotes, releaseName, releaseDate, updateURL);
mainWindow.webContents.send('notify', 'application:update-available'); mainWindow.webContents.send('application:update-available');
}); });
autoUpdater.on('error', function (e, error) { autoUpdater.on('error', function (e, error) {