Skip to content

Commit b7dfebe

Browse files
author
Waley Chen
committed
Merge pull request #224 from 10gen/INT-788-connect-to-flashes-prev-connect-dialog-bug
INT-788 connect to flashes prev connect dialog bug
2 parents 34fde77 + 0885dba commit b7dfebe

File tree

4 files changed

+23
-56
lines changed

4 files changed

+23
-56
lines changed

src/connect/index.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -438,10 +438,7 @@ var ConnectView = View.extend({
438438
window.location.origin,
439439
connection.getId())
440440
);
441-
setTimeout(this.set.bind(this, {
442-
message: ''
443-
}), 500);
444-
setTimeout(window.close, 1000);
441+
app.sendMessage('close connect');
445442
},
446443

447444
/**

src/electron/menu.js

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -221,10 +221,7 @@ function darwinMenu(menuState) {
221221
darwinCompassSubMenu()
222222
];
223223

224-
if (menuState.showConnect) {
225-
menu.push(connectSubMenu(false));
226-
}
227-
224+
menu.push(connectSubMenu(false));
228225
menu.push(editSubMenu());
229226
menu.push(viewSubMenu());
230227

@@ -262,10 +259,6 @@ var MenuState = State.extend({
262259
type: 'boolean',
263260
default: false
264261
},
265-
showConnect: {
266-
type: 'boolean',
267-
default: true
268-
},
269262
showShare: {
270263
type: 'boolean',
271264
default: false
@@ -306,7 +299,6 @@ var AppMenu = (function() {
306299

307300
debug('WINDOW\'s ' + winID + ' Menu State');
308301
debug('showCompassOverview: ' + menuState.showCompassOverview);
309-
debug('showConnect: ' + menuState.showConnect);
310302
debug('showShare: ' + menuState.showShare);
311303

312304
if (process.platform === 'darwin') {
@@ -348,10 +340,6 @@ var AppMenu = (function() {
348340
},
349341

350342
// share/hide submenu fns
351-
hideConnect: function(_window) {
352-
this.updateMenu('showConnect', false, _window);
353-
},
354-
355343
hideShare: function() {
356344
this.updateMenu('showShare', false);
357345
},
@@ -360,10 +348,6 @@ var AppMenu = (function() {
360348
this.updateMenu('showCompassOverview', true);
361349
},
362350

363-
showConnect: function() {
364-
this.updateMenu('showConnect', true);
365-
},
366-
367351
showShare: function() {
368352
this.updateMenu('showShare', true);
369353
},

src/electron/window-manager.js

Lines changed: 21 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,6 @@ var connectWindow;
3939
// since this code was laid down.
4040
var windowsOpenCount = 0;
4141

42-
function isConnectDialog(url) {
43-
return url === DEFAULT_URL;
44-
}
45-
4642
// returns true if the application is a single instance application otherwise
4743
// focus the second window (which we'll quit from) and return false
4844
// see "app.makeSingleInstance" in https://github.com/atom/electron/blob/master/docs/api/app.md
@@ -90,7 +86,7 @@ module.exports.create = function(opts) {
9086
url: DEFAULT_URL
9187
});
9288

93-
debug('creating new window');
89+
debug('creating new window: ' + opts.url);
9490
var _window = new BrowserWindow({
9591
width: opts.width,
9692
height: opts.height,
@@ -118,19 +114,6 @@ module.exports.create = function(opts) {
118114
});
119115
});
120116

121-
if (isConnectDialog(opts.url)) {
122-
AppMenu.hideConnect(_window);
123-
connectWindow = _window;
124-
connectWindow.on('focus', function() {
125-
debug('connect window focused.');
126-
connectWindow.webContents.send('message', 'connect-window-focused');
127-
});
128-
connectWindow.on('closed', function() {
129-
debug('connect window closed.');
130-
connectWindow = null;
131-
});
132-
}
133-
134117
// @see `all-windows-closed` above
135118
windowsOpenCount++;
136119
_window.on('closed', function() {
@@ -144,19 +127,18 @@ module.exports.create = function(opts) {
144127
return _window;
145128
};
146129

147-
app.on('show connect dialog', function(opts) {
148-
if (connectWindow) {
149-
connectWindow.focus();
150-
return connectWindow;
151-
}
152-
153-
opts = opts || {};
154-
opts = _.extend(opts || {}, {
130+
function createWindow(opts, url) {
131+
opts = _.extend(opts, {
155132
width: config.windows.DEFAULT_WIDTH_DIALOG,
156133
height: config.windows.DEFAULT_HEIGHT_DIALOG,
157-
url: DEFAULT_URL
134+
url: url
158135
});
159-
module.exports.create(opts);
136+
return module.exports.create(opts);
137+
}
138+
139+
app.on('close connect', function() {
140+
connectWindow.close();
141+
connectWindow = null;
160142
});
161143

162144
app.on('show about dialog', function() {
@@ -167,8 +149,17 @@ app.on('show about dialog', function() {
167149
});
168150
});
169151

170-
app.on('hide connect submenu', function() {
171-
AppMenu.hideConnect();
152+
app.on('show connect dialog', function() {
153+
if (connectWindow) {
154+
connectWindow.focus();
155+
return connectWindow;
156+
}
157+
158+
connectWindow = createWindow({}, DEFAULT_URL);
159+
connectWindow.on('focus', function() {
160+
debug('connect window focused.');
161+
connectWindow.webContents.send('message', 'connect-window-focused');
162+
});
172163
});
173164

174165
app.on('hide share submenu', function() {
@@ -179,10 +170,6 @@ app.on('show compass overview submenu', function() {
179170
AppMenu.showCompassOverview();
180171
});
181172

182-
app.on('show connect submenu', function() {
183-
AppMenu.showConnect();
184-
});
185-
186173
app.on('show share submenu', function() {
187174
AppMenu.showShare();
188175
});

src/home/index.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ var HomeView = View.extend({
5151
app.instance.fetch();
5252

5353
app.sendMessage('show compass overview submenu');
54-
app.sendMessage('show connect submenu');
5554
},
5655
render: function() {
5756
this.renderWithTemplate(this);

0 commit comments

Comments
 (0)