Skip to content

Commit eacce18

Browse files
author
Thomas Rueckstiess
committed
set up ipc between main and render process
zero-state for no collections now has functioning link to re-open the connect dialog.
1 parent 74994d1 commit eacce18

File tree

5 files changed

+20
-12
lines changed

5 files changed

+20
-12
lines changed

src/app.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -223,13 +223,6 @@ var Application = View.extend({
223223
event.preventDefault();
224224
this.router.history.navigate(pathname);
225225
}
226-
},
227-
sendMessage: function(msg) {
228-
ipc.send('message', msg);
229-
},
230-
onMessageReceived: function(msg) {
231-
debug('message received from main process:', msg);
232-
this.trigger(msg);
233226
}
234227
});
235228

@@ -262,6 +255,13 @@ app.extend({
262255
isFeatureEnabled: function(id) {
263256
return FEATURES[id] === true;
264257
},
258+
sendMessage: function(msg) {
259+
ipc.send('message', msg);
260+
},
261+
onMessageReceived: function(msg) {
262+
debug('message received from main process:', msg);
263+
this.trigger(msg);
264+
},
265265
init: function() {
266266
domReady(function() {
267267
state.render();
@@ -298,7 +298,7 @@ app.extend({
298298
});
299299
});
300300
// set up ipc
301-
ipc.on('message', state.onMessageReceived.bind(this));
301+
ipc.on('message', this.onMessageReceived.bind(this));
302302
},
303303
navigate: state.navigate.bind(state)
304304
});

src/electron/config/windows.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
/**
66
* The outer dimensions to use for new windows.
77
*/
8-
exports.DEFAULT_WIDTH = 1024;
9-
exports.DEFAULT_HEIGHT = 700;
8+
exports.DEFAULT_WIDTH = 1280;
9+
exports.DEFAULT_HEIGHT = 800;
1010

1111
/**
1212
* The outer window dimensions to use for new dialog

src/electron/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ if (!process.env.NODE_ENV) {
77
// will be created in `/tmp/Compass`
88
// (`~\AppData\Local\Temp\Compass` on Windows).
99
require('./crash-reporter');
10+
var debug = require('debug')('electron:index');
1011

1112
if (!require('electron-squirrel-startup')) {
1213
var app = require('app');
1314
var serverctl = require('./scout-server-ctl');
14-
var debug = require('debug')('scout-electron');
1515

1616
app.on('window-all-closed', function() {
1717
debug('All windows closed. Quitting app.');

src/electron/window-manager.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,3 +128,9 @@ app.on('show connect dialog', function(opts) {
128128
app.on('ready', function() {
129129
app.emit('show connect dialog');
130130
});
131+
132+
var ipc = require('ipc');
133+
ipc.on('message', function(event, msg) {
134+
debug('message received in main process', msg);
135+
app.emit(msg);
136+
});

src/home/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ var HomeView = View.extend({
4848
app.instance.fetch();
4949
},
5050
onInstanceFetched: function() {
51-
if(_.size(app.instance.collections) === 0) {
51+
if (app.instance.collections.length === 0) {
5252
this.showNoCollectionsZeroState = true;
5353
} else {
5454
this.showDefaultZeroState = true;
@@ -82,6 +82,8 @@ var HomeView = View.extend({
8282
},
8383
onClickShowConnectWindow: function() {
8484
// code to close current connection window and open connect dialog
85+
app.sendMessage('show connect dialog');
86+
window.close();
8587
},
8688
template: require('./index.jade'),
8789
subviews: {

0 commit comments

Comments
 (0)