|
|
@@ -1382,14 +1382,26 @@ export default class ChatRoom extends Listenable {
|
|
1382
|
1382
|
|
|
1383
|
1383
|
/**
|
|
1384
|
1384
|
* Adds the key to the presence map, overriding any previous value.
|
|
1385
|
|
- * @param key
|
|
1386
|
|
- * @param values
|
|
|
1385
|
+ * @param key The key to add or replace.
|
|
|
1386
|
+ * @param values The new values.
|
|
|
1387
|
+ * @returns {boolean|null} <tt>true</tt> if the operation succeeded or <tt>false</tt> when no add or replce was
|
|
|
1388
|
+ * performed as the value was already there.
|
|
1387
|
1389
|
*/
|
|
1388
|
|
- addToPresence(key, values) {
|
|
|
1390
|
+ addOrReplaceInPresence(key, values) {
|
|
1389
|
1391
|
values.tagName = key;
|
|
|
1392
|
+
|
|
|
1393
|
+ const matchingNodes = this.presMap.nodes.filter(node => key === node.tagName);
|
|
|
1394
|
+
|
|
|
1395
|
+ // if we have found just one, let's check is it the same
|
|
|
1396
|
+ if (matchingNodes.length === 1 && isEqual(matchingNodes[0], values)) {
|
|
|
1397
|
+ return false;
|
|
|
1398
|
+ }
|
|
|
1399
|
+
|
|
1390
|
1400
|
this.removeFromPresence(key);
|
|
1391
|
1401
|
this.presMap.nodes.push(values);
|
|
1392
|
1402
|
this.presenceUpdateTime = Date.now();
|
|
|
1403
|
+
|
|
|
1404
|
+ return true;
|
|
1393
|
1405
|
}
|
|
1394
|
1406
|
|
|
1395
|
1407
|
/**
|
|
|
@@ -1515,7 +1527,7 @@ export default class ChatRoom extends Listenable {
|
|
1515
|
1527
|
* @param mute
|
|
1516
|
1528
|
*/
|
|
1517
|
1529
|
addAudioInfoToPresence(mute) {
|
|
1518
|
|
- this.addToPresence(
|
|
|
1530
|
+ return this.addOrReplaceInPresence(
|
|
1519
|
1531
|
'audiomuted',
|
|
1520
|
1532
|
{
|
|
1521
|
1533
|
attributes: { 'xmlns': 'http://jitsi.org/jitmeet/audio' },
|
|
|
@@ -1529,10 +1541,8 @@ export default class ChatRoom extends Listenable {
|
|
1529
|
1541
|
* @param callback
|
|
1530
|
1542
|
*/
|
|
1531
|
1543
|
sendAudioInfoPresence(mute, callback) {
|
|
1532
|
|
- this.addAudioInfoToPresence(mute);
|
|
1533
|
|
-
|
|
1534
|
1544
|
// FIXME resend presence on CONNECTED
|
|
1535
|
|
- this.sendPresence();
|
|
|
1545
|
+ this.addAudioInfoToPresence(mute) && this.sendPresence();
|
|
1536
|
1546
|
if (callback) {
|
|
1537
|
1547
|
callback();
|
|
1538
|
1548
|
}
|
|
|
@@ -1543,7 +1553,7 @@ export default class ChatRoom extends Listenable {
|
|
1543
|
1553
|
* @param mute
|
|
1544
|
1554
|
*/
|
|
1545
|
1555
|
addVideoInfoToPresence(mute) {
|
|
1546
|
|
- this.addToPresence(
|
|
|
1556
|
+ return this.addOrReplaceInPresence(
|
|
1547
|
1557
|
'videomuted',
|
|
1548
|
1558
|
{
|
|
1549
|
1559
|
attributes: { 'xmlns': 'http://jitsi.org/jitmeet/video' },
|
|
|
@@ -1556,8 +1566,7 @@ export default class ChatRoom extends Listenable {
|
|
1556
|
1566
|
* @param mute
|
|
1557
|
1567
|
*/
|
|
1558
|
1568
|
sendVideoInfoPresence(mute) {
|
|
1559
|
|
- this.addVideoInfoToPresence(mute);
|
|
1560
|
|
- this.sendPresence();
|
|
|
1569
|
+ this.addVideoInfoToPresence(mute) && this.sendPresence();
|
|
1561
|
1570
|
}
|
|
1562
|
1571
|
|
|
1563
|
1572
|
/**
|