Explorar o código

Bugfix. Server disco features forgotten between logouts.

JC Brand %!s(int64=8) %!d(string=hai) anos
pai
achega
d9a61746a2
Modificáronse 2 ficheiros con 10 adicións e 6 borrados
  1. 3 2
      CHANGES.md
  2. 7 4
      src/converse-core.js

+ 3 - 2
CHANGES.md

@@ -2,8 +2,9 @@
 
 
 ## 3.2.0 (Unreleased)
 ## 3.2.0 (Unreleased)
 
 
-### New features
+### New features and improvements
 - Add support for Emojis (either native, or via <a href="https://www.emojione.com/">Emojione</a>). [jcbrand]
 - Add support for Emojis (either native, or via <a href="https://www.emojione.com/">Emojione</a>). [jcbrand]
+- Add JID validation in the contact add form. [jcbrand]
 
 
 ### New configuration settings
 ### New configuration settings
 * The `visible_toolbar_buttons.emoticons` configuration option is now changed to `visible_toolbar_buttons.emoji`.
 * The `visible_toolbar_buttons.emoticons` configuration option is now changed to `visible_toolbar_buttons.emoji`.
@@ -22,8 +23,8 @@
 - #866 Add babel in order to support ES2015 syntax [jcbrand]
 - #866 Add babel in order to support ES2015 syntax [jcbrand]
 
 
 #### Bugfixes:
 #### Bugfixes:
-
 - Room name wasn't being updated after changing it in the configuration form. [jcbrand]
 - Room name wasn't being updated after changing it in the configuration form. [jcbrand]
+- Server disco features were "forgotten" after logging out and then logging in again. [jcbrand]
 
 
 ## 3.1.1 (2017-07-12)
 ## 3.1.1 (2017-07-12)
 
 

+ 7 - 4
src/converse-core.js

@@ -583,7 +583,7 @@
             });
             });
 
 
         this.initSession = function () {
         this.initSession = function () {
-            this.session = new this.Session();
+            this.session = new Backbone.Model();
             const id = b64_sha1('converse.bosh-session');
             const id = b64_sha1('converse.bosh-session');
             this.session.id = id; // Appears to be necessary for backbone.browserStorage
             this.session.id = id; // Appears to be necessary for backbone.browserStorage
             this.session.browserStorage = new Backbone.BrowserStorage[_converse.storage](id);
             this.session.browserStorage = new Backbone.BrowserStorage[_converse.storage](id);
@@ -1859,8 +1859,6 @@
             }
             }
         });
         });
 
 
-        this.Session = Backbone.Model; // General session settings to be saved to sessionStorage.
-        this.Feature = Backbone.Model;
         this.Features = Backbone.Collection.extend({
         this.Features = Backbone.Collection.extend({
             /* Service Discovery
             /* Service Discovery
              * -----------------
              * -----------------
@@ -1869,13 +1867,17 @@
              * See XEP-0030 for more details: http://xmpp.org/extensions/xep-0030.html
              * See XEP-0030 for more details: http://xmpp.org/extensions/xep-0030.html
              * All features are shown here: http://xmpp.org/registrar/disco-features.html
              * All features are shown here: http://xmpp.org/registrar/disco-features.html
              */
              */
-            model: _converse.Feature,
+            model: Backbone.Model,
             initialize () {
             initialize () {
                 this.addClientIdentities().addClientFeatures();
                 this.addClientIdentities().addClientFeatures();
                 this.browserStorage = new Backbone.BrowserStorage[_converse.storage](
                 this.browserStorage = new Backbone.BrowserStorage[_converse.storage](
                     b64_sha1(`converse.features${_converse.bare_jid}`)
                     b64_sha1(`converse.features${_converse.bare_jid}`)
                 );
                 );
                 this.on('add', this.onFeatureAdded, this);
                 this.on('add', this.onFeatureAdded, this);
+                this.fetchFeatures();
+            },
+
+            fetchFeatures () {
                 if (this.browserStorage.records.length === 0) {
                 if (this.browserStorage.records.length === 0) {
                     // browserStorage is empty, so we've likely never queried this
                     // browserStorage is empty, so we've likely never queried this
                     // domain for features yet
                     // domain for features yet
@@ -2164,6 +2166,7 @@
             delete this.chatboxes.browserStorage;
             delete this.chatboxes.browserStorage;
             if (this.features) {
             if (this.features) {
                 this.features.reset();
                 this.features.reset();
+                this.features.browserStorage._clear();
             }
             }
             this.session.destroy();
             this.session.destroy();
             window.removeEventListener('click', _converse.onUserActivity);
             window.removeEventListener('click', _converse.onUserActivity);