Skip to content
This repository was archived by the owner on May 16, 2019. It is now read-only.

Commit 6c7889f

Browse files
committed
Merge pull request #1484 from rmisio/server-config-tweaks
Server config tweaks
2 parents c24370d + 5f4bc2e commit 6c7889f

File tree

2 files changed

+28
-19
lines changed

2 files changed

+28
-19
lines changed

js/main.js

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -100,30 +100,40 @@ app.serverConfigs.fetch().done(() => {
100100
defaultConfig = app.serverConfigs.create({
101101
name: polyglot.t('serverConnectModal.defaultServerName'),
102102
default: true
103-
})
103+
});
104104

105105
// migrate any existing connection from the
106106
// old single config set-up (_serverConfig-1)
107107
if (oldConfig = localStorage['_serverConfig-1']) {
108108
oldConfig = JSON.parse(oldConfig);
109109

110-
app.serverConfigs.setActive(
111-
app.serverConfigs.create(
112-
__.extend(
113-
{},
114-
__.omit(oldConfig, ['local_username', 'local_password', 'id']),
115-
{ name: polyglot.t('serverConnectModal.portedConnectionName') }
116-
)
117-
).id
118-
);
119-
120-
if (oldConfig.local_username && oldConfig.local_password) {
121-
defaultConfig.save({
122-
local_username: oldConfig.local_username,
123-
local_password: oldConfig.local_password
124-
});
110+
// don't create a ported connection if it's the same as the default one
111+
if (
112+
oldConfig.server_ip +
113+
oldConfig.rest_api_port +
114+
oldConfig.api_socket_port +
115+
oldConfig.SSL !==
116+
defaultConfig.get('server_ip') +
117+
defaultConfig.get('rest_api_port') +
118+
defaultConfig.get('api_socket_port') +
119+
defaultConfig.get('SSL')
120+
) {
121+
app.serverConfigs.setActive(
122+
app.serverConfigs.create(
123+
__.extend(
124+
{},
125+
__.omit(oldConfig, ['local_username', 'local_password', 'id']),
126+
{ name: polyglot.t('serverConnectModal.portedConnectionName') }
127+
)
128+
).id
129+
);
125130
}
126131

132+
defaultConfig.save({
133+
username: oldConfig.username,
134+
password: oldConfig.password
135+
});
136+
127137
localStorage.removeItem('_serverConfig-1');
128138
} else {
129139
app.serverConfigs.setActive(defaultConfig.id);
@@ -455,7 +465,7 @@ app.connectHeartbeatSocket();
455465
app.serverConnectModal = new ServerConnectModal().render();
456466
app.serverConnectModal.on('connected', () => {
457467
if (profileLoaded) {
458-
// If we've already loaded called loadProfile() and then, we connect
468+
// If we've already called loadProfile() and then, we connect
459469
// to a new server (or reconnect to the same server) we'll reload the
460470
// app since some of the "global" components (Router, PageNav,
461471
// SocketView...) were not designed to handle a new connection.

js/views/serverConnectModal.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -280,14 +280,13 @@ module.exports = BaseModal.extend({
280280
loginRequest = app.login().done(function(data) {
281281
if (data.success) {
282282
conclude(false, data);
283+
self.trigger('connected');
283284
} else {
284285
if (data.reason === 'too many attempts') {
285286
conclude(true, 'failed-auth-too-many');
286287
} else {
287288
conclude(true, 'failed-auth');
288289
}
289-
290-
self.trigger('connected', false);
291290
}
292291
}).fail(function(jqxhr) {
293292
if (jqxhr.statusText === 'abort') return;

0 commit comments

Comments
 (0)