Ver Fonte

Don't show the features heading if we don't know of any

JC Brand há 8 anos atrás
pai
commit
78865bbccb
2 ficheiros alterados com 15 adições e 13 exclusões
  1. 13 13
      src/converse-muc.js
  2. 2 0
      src/templates/chatroom_features.html

+ 13 - 13
src/converse-muc.js

@@ -75,6 +75,12 @@
     Strophe.addNamespace('MUC_ROOMCONF', Strophe.NS.MUC + "#roomconfig");
     Strophe.addNamespace('MUC_USER', Strophe.NS.MUC + "#user");
 
+    var ROOM_FEATURES = [
+        'passwordprotected', 'unsecured', 'hidden',
+        'public', 'membersonly', 'open', 'persistent',
+        'temporary', 'nonanonymous', 'semianonymous',
+        'moderated', 'unmoderated', 'mam_enabled'
+    ];
     var ROOMSTATUS = {
         CONNECTED: 0,
         CONNECTING: 1,
@@ -294,27 +300,18 @@
                  * are correct, for example that the "type" is set to
                  * "chatroom".
                  */
+                settings = _.extend(
+                    _.zipObject(ROOM_FEATURES, _.map(ROOM_FEATURES, _.stubFalse)),
+                    settings
+                );
                 return _converse.chatboxviews.showChat(
                     _.extend({
                         'affiliation': null,
                         'connection_status': ROOMSTATUS.DISCONNECTED,
                         'description': '',
                         'features_fetched': false,
-                        'hidden': false,
-                        'mam_enabled': false,
-                        'membersonly': false,
-                        'moderated': false,
-                        'nonanonymous': false,
-                        'open': false,
-                        'passwordprotected': false,
-                        'persistent': false,
-                        'public': false,
                         'roomconfig': {},
-                        'semianonymous': false,
-                        'temporary': false,
                         'type': 'chatroom',
-                        'unmoderated': false,
-                        'unsecured': false,
                     }, settings)
                 );
             };
@@ -2007,9 +2004,12 @@
                 },
 
                 renderRoomFeatures: function () {
+                    var picks = _.pick(this.chatroomview.model.attributes, ROOM_FEATURES),
+                        iteratee = function (a, v) { return a || v; };
                     this.$('.chatroom-features').html(
                         tpl_chatroom_features(
                             _.extend(this.chatroomview.model.toJSON(), {
+                                'has_features': _.reduce(_.values(picks), iteratee),
                                 'label_features': __('Features'),
                                 'label_hidden': __('Hidden'),
                                 'label_mam_enabled': __('Message archiving'),

+ 2 - 0
src/templates/chatroom_features.html

@@ -1,4 +1,6 @@
+{[ if (has_features) { ]}
 <p class="occupants-heading">{{{label_features}}}</p>
+{[ } ]}
 <ul class="features-list">
 {[ if (passwordprotected) { ]}
 <li class="feature" title="{{{ tt_passwordprotected }}}"><span class="icon-lock-2"></span>{{{ label_passwordprotected }}}</li>