in react/features/breakout-rooms/actions.js [161:248]
export function moveToRoom(roomId?: string) {
return async (dispatch: Dispatch<any>, getState: Function) => {
const mainRoomId = getMainRoom(getState)?.id;
let _roomId = roomId || mainRoomId;
// Check if we got a full JID.
// $FlowExpectedError
if (_roomId?.indexOf('@') !== -1) {
// $FlowExpectedError
const [ id, ...domainParts ] = _roomId.split('@');
// On mobile we first store the room and the connection is created
// later, so let's attach the domain to the room String object as
// a little hack.
// eslint-disable-next-line no-new-wrappers
_roomId = new String(id);
// $FlowExpectedError
_roomId.domain = domainParts.join('@');
}
// $FlowExpectedError
const roomIdStr = _roomId?.toString();
const goToMainRoom = roomIdStr === mainRoomId;
const rooms = getBreakoutRooms(getState);
const targetRoom = rooms[roomIdStr];
if (!targetRoom) {
logger.warn(`Unknown room: ${targetRoom}`);
return;
}
dispatch({
type: _RESET_BREAKOUT_ROOMS
});
if (navigator.product === 'ReactNative') {
const conference = getCurrentConference(getState);
const { audio, video } = getState()['features/base/media'];
dispatch(conferenceWillLeave(conference));
try {
await conference.leave();
} catch (error) {
logger.warn('JitsiConference.leave() rejected with:', error);
dispatch(conferenceLeft(conference));
}
dispatch(clearNotifications());
// dispatch(setRoom(_roomId));
dispatch(createConference(_roomId));
dispatch(setAudioMuted(audio.muted));
dispatch(setVideoMuted(video.muted));
} else {
try {
APP.conference.leaveRoom(false /* doDisconnect */);
} catch (error) {
logger.warn('APP.conference.leaveRoom() rejected with:', error);
// TODO: revisit why we don't dispatch CONFERENCE_LEFT here.
}
APP.conference.joinRoom(_roomId);
}
if (goToMainRoom) {
dispatch(showNotification({
titleKey: 'breakoutRooms.notifications.joinedTitle',
descriptionKey: 'breakoutRooms.notifications.joinedMainRoom',
concatText: true,
maxLines: 2
}, NOTIFICATION_TIMEOUT_TYPE.MEDIUM));
} else {
dispatch(showNotification({
titleKey: 'breakoutRooms.notifications.joinedTitle',
descriptionKey: 'breakoutRooms.notifications.joined',
descriptionArguments: { name: targetRoom.name },
concatText: true,
maxLines: 2
}, NOTIFICATION_TIMEOUT_TYPE.MEDIUM));
}
};
}