Parcourir la source

Bugfix. Don't hide the roster filter when it's actually being used

The filter was being hidden if the roster was not big enough to require a
scrollbar, but the roster might not be big enough because the roster is
actually being applied.
JC Brand il y a 9 ans
Parent
commit
0d2e49a976
2 fichiers modifiés avec 15 ajouts et 6 suppressions
  1. 2 2
      src/converse-core.js
  2. 13 4
      src/converse-rosterview.js

+ 2 - 2
src/converse-core.js

@@ -1438,10 +1438,10 @@
             },
 
             constructPresence: function (type, status_message) {
-                if (typeof type === 'undefined') {
+                if (typeof type !== 'string') {
                     type = this.get('status') || 'online';
                 }
-                if (typeof status_message === 'undefined') {
+                if (typeof status_message !== 'string') {
                     status_message = this.get('status_message');
                 }
                 var presence;

+ 13 - 4
src/converse-rosterview.js

@@ -153,6 +153,17 @@
                     });
                 }, 250),
 
+                isActive: function () {
+                    /* Returns true if the filter is enabled (i.e. if the user
+                     * has added values to the filter).
+                     */
+                    if (this.model.get('filter_type') === 'state' ||
+                        this.model.get('filter_text')) {
+                        return true;
+                    }
+                    return false;
+                },
+
                 show: function () {
                     if (this.$el.is(':visible')) { return this; }
                     this.$el.show();
@@ -256,7 +267,7 @@
                     }
                     if (this.$roster.hasScrollBar()) {
                         this.filter_view.show();
-                    } else {
+                    } else if (!this.filter_view.isActive()) {
                         this.filter_view.hide();
                     }
                     return this;
@@ -281,9 +292,7 @@
                                          * fetching the roster we are ready to receive presence
                                          * updates from our contacts.
                                          */
-                                        converse.roster.fetchFromServer(function () {
-                                            converse.xmppstatus.sendPresence();
-                                        });
+                                        converse.roster.fetchFromServer(converse.xmppstatus.sendPresence);
                                     } else if (converse.send_initial_presence) {
                                         /* We're not going to fetch the roster again because we have
                                          * it already cached in sessionStorage, but we still need to