Ver código fonte

Initialise lock state on room join.

tags/v0.0.2
damencho 9 anos atrás
pai
commit
cf80ff9b0a
1 arquivos alterados com 7 adições e 1 exclusões
  1. 7
    1
      modules/xmpp/ChatRoom.js

+ 7
- 1
modules/xmpp/ChatRoom.js Ver arquivo

@@ -202,7 +202,8 @@ ChatRoom.prototype.discoRoomInfo = function () {
202 202
     .c('query', {xmlns: Strophe.NS.DISCO_INFO});
203 203
 
204 204
   this.connection.sendIQ(getInfo, function (result) {
205
-    var locked = $(result).find('>query>feature[var="muc_passwordprotected"]').length;
205
+    var locked = $(result).find('>query>feature[var="muc_passwordprotected"]')
206
+        .length === 1;
206 207
     if (locked != this.locked) {
207 208
       this.eventEmitter.emit(XMPPEvents.MUC_LOCK_CHANGED, locked);
208 209
       this.locked = locked;
@@ -307,6 +308,11 @@ ChatRoom.prototype.onPresence = function (pres) {
307 308
             var now = this.connectionTimes["muc.joined"] =
308 309
                 window.performance.now();
309 310
             logger.log("(TIME) MUC joined:\t", now);
311
+
312
+            // set correct initial state of locked
313
+            if (this.password)
314
+                this.locked = true;
315
+
310 316
             this.eventEmitter.emit(XMPPEvents.MUC_JOINED);
311 317
         }
312 318
     } else if (this.members[from] === undefined) {

Carregando…
Cancelar
Salvar