fix(breakout-rooms) close room before removing it (#10956)

This commit is contained in:
Mihaela Dumitru 2022-02-14 12:40:44 +02:00 committed by GitHub
parent 59065d10f8
commit 79877e56f0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 27 additions and 1 deletions

View File

@ -33,7 +33,8 @@ import { _RESET_BREAKOUT_ROOMS, _UPDATE_ROOM_COUNTER } from './actionTypes';
import { FEATURE_KEY } from './constants';
import {
getBreakoutRooms,
getMainRoom
getMainRoom,
getRoomByJid
} from './functions';
import logger from './logger';
@ -97,6 +98,17 @@ export function closeBreakoutRoom(roomId: string) {
export function removeBreakoutRoom(breakoutRoomJid: string) {
return (dispatch: Dispatch<any>, getState: Function) => {
sendAnalytics(createBreakoutRoomsEvent('remove'));
const room = getRoomByJid(getState, breakoutRoomJid);
if (!room) {
logger.error('The room to remove was not found.');
return;
}
if (Object.keys(room.participants).length > 0) {
dispatch(closeBreakoutRoom(room.id));
}
// $FlowExpectedError
getCurrentConference(getState)?.getBreakoutRooms()

View File

@ -29,6 +29,20 @@ export const getMainRoom = (stateful: Function | Object) => {
return _.find(rooms, (room: Object) => room.isMainRoom);
};
/**
* Returns the room by Jid.
*
* @param {Function|Object} stateful - The redux store, the redux
* {@code getState} function, or the redux state itself.
* @param {string} roomJid - The jid of the room.
* @returns {Object|undefined} The main room object, or undefined.
*/
export const getRoomByJid = (stateful: Function | Object, roomJid: string): Object => {
const rooms = getBreakoutRooms(stateful);
return _.find(rooms, (room: Object) => room.jid === roomJid);
};
/**
* Returns the id of the current room.
*