fix(external_api): Fix number of participants in meeting (#12052)

This commit is contained in:
Duduman Bogdan Vlad
2022-09-06 09:51:38 +03:00
committed by yanas
parent fb402c7131
commit b709d079c9
9 changed files with 154 additions and 18 deletions

View File

@@ -619,6 +619,9 @@ export default class JitsiMeetExternalAPI extends EventEmitter {
case 'video-quality-changed':
this._videoQuality = data.videoQuality;
break;
case 'breakout-rooms-updated':
this.updateNumberOfParticipants(data.rooms);
break;
case 'local-storage-changed':
jitsiLocalStorage.setItem('jitsiLocalStorage', data.localStorageContent);
@@ -638,6 +641,40 @@ export default class JitsiMeetExternalAPI extends EventEmitter {
});
}
/**
* Update number of participants based on all rooms.
*
* @param {Object} rooms - Rooms available rooms in the conference.
* @returns {void}
*/
updateNumberOfParticipants(rooms) {
if (!rooms || !Object.keys(rooms).length) {
return;
}
const allParticipants = Object.keys(rooms).reduce((prev, roomItemKey) => {
if (rooms[roomItemKey]?.participants) {
return Object.keys(rooms[roomItemKey].participants).length + prev;
}
return prev;
}, 0);
this._numberOfParticipants = allParticipants;
}
/**
* Returns the rooms info in the conference.
*
* @returns {Object} Rooms info.
*/
async getRoomsInfo() {
return this._transport.sendRequest({
name: 'rooms-info'
});
}
/**
* Adds event listener to Meet Jitsi.
*
@@ -1101,7 +1138,7 @@ export default class JitsiMeetExternalAPI extends EventEmitter {
}
/**
* Returns the number of participants in the conference. The local
* Returns the number of participants in the conference from all rooms. The local
* participant is included.
*
* @returns {int} The number of participants in the conference.