Bläddra i källkod

fix: Skips sending an extra presence on join. (#1174)

* fix: Skips sending an extra presence on join.

* Renames the variable names.
dev1
Дамян Минков 5 år sedan
förälder
incheckning
3c8d411c96
Inget konto är kopplat till bidragsgivarens mejladress
2 ändrade filer med 15 tillägg och 10 borttagningar
  1. 0
    4
      JitsiConference.js
  2. 15
    6
      modules/xmpp/ChatRoom.js

+ 0
- 4
JitsiConference.js Visa fil

@@ -839,9 +839,6 @@ JitsiConference.prototype.removeCommand = function(name) {
839 839
  */
840 840
 JitsiConference.prototype.setDisplayName = function(name) {
841 841
     if (this.room) {
842
-        // remove previously set nickname
843
-        this.room.removeFromPresence('nick');
844
-
845 842
         this.room.addToPresence('nick', {
846 843
             attributes: { xmlns: 'http://jabber.org/protocol/nick' },
847 844
             value: name
@@ -2304,7 +2301,6 @@ JitsiConference.prototype.setStartMutedPolicy = function(policy) {
2304 2301
         return;
2305 2302
     }
2306 2303
     this.startMutedPolicy = policy;
2307
-    this.room.removeFromPresence('startmuted');
2308 2304
     this.room.addToPresence('startmuted', {
2309 2305
         attributes: {
2310 2306
             audio: policy.audio,

+ 15
- 6
modules/xmpp/ChatRoom.js Visa fil

@@ -162,6 +162,8 @@ export default class ChatRoom extends Listenable {
162 162
                 }
163 163
             });
164 164
         }
165
+
166
+        this.presenceUpdateTime = Date.now();
165 167
     }
166 168
 
167 169
     /**
@@ -223,6 +225,10 @@ export default class ChatRoom extends Listenable {
223 225
         }
224 226
 
225 227
         parser.json2packet(this.presMap.nodes, pres);
228
+
229
+        // we store time we last synced presence state
230
+        this.presenceSyncTime = Date.now();
231
+
226 232
         this.connection.send(pres);
227 233
         if (fromJoin) {
228 234
             // XXX We're pressed for time here because we're beginning a complex
@@ -518,7 +524,10 @@ export default class ChatRoom extends Listenable {
518 524
 
519 525
                 // Re-send presence in case any presence updates were added,
520 526
                 // but blocked from sending, during the join process.
521
-                this.sendPresence();
527
+                // send the presence only if there was a modification after we had synced it
528
+                if (this.presenceUpdateTime >= this.presenceSyncTime) {
529
+                    this.sendPresence();
530
+                }
522 531
 
523 532
                 this.eventEmitter.emit(XMPPEvents.MUC_JOINED);
524 533
 
@@ -1143,7 +1152,7 @@ export default class ChatRoom extends Listenable {
1143 1152
     /* eslint-enable max-params */
1144 1153
 
1145 1154
     /**
1146
-     *
1155
+     * Adds the key to the presence map, overriding any previous value.
1147 1156
      * @param key
1148 1157
      * @param values
1149 1158
      */
@@ -1151,10 +1160,11 @@ export default class ChatRoom extends Listenable {
1151 1160
         values.tagName = key;
1152 1161
         this.removeFromPresence(key);
1153 1162
         this.presMap.nodes.push(values);
1163
+        this.presenceUpdateTime = Date.now();
1154 1164
     }
1155 1165
 
1156 1166
     /**
1157
-     * Retreives a value from the presence map.
1167
+     * Retrieves a value from the presence map.
1158 1168
      *
1159 1169
      * @param {string} key - The key to find the value for.
1160 1170
      * @returns {Object?}
@@ -1164,13 +1174,14 @@ export default class ChatRoom extends Listenable {
1164 1174
     }
1165 1175
 
1166 1176
     /**
1167
-     *
1177
+     * Removes a key from the presence map.
1168 1178
      * @param key
1169 1179
      */
1170 1180
     removeFromPresence(key) {
1171 1181
         const nodes = this.presMap.nodes.filter(node => key !== node.tagName);
1172 1182
 
1173 1183
         this.presMap.nodes = nodes;
1184
+        this.presenceUpdateTime = Date.now();
1174 1185
     }
1175 1186
 
1176 1187
     /**
@@ -1275,7 +1286,6 @@ export default class ChatRoom extends Listenable {
1275 1286
      * @param mute
1276 1287
      */
1277 1288
     addAudioInfoToPresence(mute) {
1278
-        this.removeFromPresence('audiomuted');
1279 1289
         this.addToPresence(
1280 1290
             'audiomuted',
1281 1291
             {
@@ -1304,7 +1314,6 @@ export default class ChatRoom extends Listenable {
1304 1314
      * @param mute
1305 1315
      */
1306 1316
     addVideoInfoToPresence(mute) {
1307
-        this.removeFromPresence('videomuted');
1308 1317
         this.addToPresence(
1309 1318
             'videomuted',
1310 1319
             {

Laddar…
Avbryt
Spara