@@ -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();
455465app . serverConnectModal = new ServerConnectModal ( ) . render ( ) ;
456466app . 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.
0 commit comments