Sfoglia il codice sorgente

Only close controlbox when logging out

Not when the connection failed due to other reasons (like wrong credentials).
JC Brand 8 anni fa
parent
commit
af42bc0696
2 ha cambiato i file con 6 aggiunte e 2 eliminazioni
  1. 2 2
      src/converse-controlbox.js
  2. 4 0
      src/converse-core.js

+ 2 - 2
src/converse-controlbox.js

@@ -149,7 +149,7 @@
 
                 closeAllChatBoxes: function () {
                     this.each(function (view) {
-                        if (!converse.connection.connected ||
+                        if (converse.disconnection_cause === converse.LOGOUT ||
                             view.model.get('id') !== 'controlbox') {
                                 view.close();
                         }
@@ -241,7 +241,7 @@
                     if (this.model.get('connected')) {
                         this.insertRoster();
                     }
-                    if (typeof this.model.get('closed')==='undefined') {
+                    if (_.isUndefined(this.model.get('closed'))) {
                         this.model.set('closed', !converse.show_controlbox_by_default);
                     }
                     if (!this.model.get('closed')) {

+ 4 - 0
src/converse-core.js

@@ -479,6 +479,10 @@
                 converse.connection.disconnect(__('Authentication Failed'));
                 converse.setDisconnectionCause(status, condition, true);
             } else if (status === Strophe.Status.CONNFAIL) {
+                converse.giveFeedback(
+                    __('Connection failed'), 'error',
+                    __('An error occurred while connecting to the chat server: '+condition)
+                );
                 converse.setDisconnectionCause(status, condition);
             } else if (status === Strophe.Status.DISCONNECTING) {
                 converse.setDisconnectionCause(status, condition);