fix(breakout-rooms) close room before removing it (#10956)
This commit is contained in:
parent
59065d10f8
commit
79877e56f0
|
@ -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()
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue