fix(breakout-rooms) make sure the default name is monotonically increasing

This commit is contained in:
Saúl Ibarra Corretgé 2021-11-25 12:43:42 +01:00 committed by Saúl Ibarra Corretgé
parent fc16bfa6cb
commit 4a5982da1f
5 changed files with 39 additions and 17 deletions

View File

@ -5,3 +5,8 @@
*
*/
export const UPDATE_BREAKOUT_ROOMS = 'UPDATE_BREAKOUT_ROOMS';
/**
* The type of (redux) action to update the room counter locally.
*/
export const _UPDATE_ROOM_COUNTER = '_UPDATE_ROOM_COUNTER';

View File

@ -15,6 +15,8 @@ import { setAudioMuted, setVideoMuted } from '../base/media';
import { getRemoteParticipants } from '../base/participants';
import { clearNotifications } from '../notifications';
import { _UPDATE_ROOM_COUNTER } from './actionTypes';
import { FEATURE_KEY } from './constants';
import {
getBreakoutRooms,
getMainRoom
@ -31,16 +33,19 @@ declare var APP: Object;
*/
export function createBreakoutRoom(name?: string) {
return (dispatch: Dispatch<any>, getState: Function) => {
const rooms = getBreakoutRooms(getState);
// TODO: remove this once we add UI to customize the name.
const index = Object.keys(rooms).length;
const subject = name || i18next.t('breakoutRooms.defaultName', { index });
const state = getState();
let { roomCounter } = state[FEATURE_KEY];
const subject = name || i18next.t('breakoutRooms.defaultName', { index: ++roomCounter });
sendAnalytics(createBreakoutRoomsEvent('create'));
dispatch({
type: _UPDATE_ROOM_COUNTER,
roomCounter
});
// $FlowExpectedError
getCurrentConference(getState)?.getBreakoutRooms()
getCurrentConference(state)?.getBreakoutRooms()
?.createBreakoutRoom(subject);
};
}

View File

@ -20,11 +20,12 @@ StateListenerRegistry.register(
dispatch(moveToRoom(roomId));
});
conference.on(JitsiConferenceEvents.BREAKOUT_ROOMS_UPDATED, rooms => {
conference.on(JitsiConferenceEvents.BREAKOUT_ROOMS_UPDATED, ({ rooms, roomCounter }) => {
logger.debug('Room list updated');
dispatch({
type: UPDATE_BREAKOUT_ROOMS,
rooms
rooms,
roomCounter
});
});
}

View File

@ -2,20 +2,33 @@
import { ReducerRegistry } from '../base/redux';
import { UPDATE_BREAKOUT_ROOMS } from './actionTypes';
import {
_UPDATE_ROOM_COUNTER,
UPDATE_BREAKOUT_ROOMS
} from './actionTypes';
import { FEATURE_KEY } from './constants';
const DEFAULT_STATE = {
rooms: {},
roomCounter: 0
};
/**
* Listen for actions for the breakout-rooms feature.
*/
ReducerRegistry.register(FEATURE_KEY, (state = { rooms: {} }, action) => {
ReducerRegistry.register(FEATURE_KEY, (state = DEFAULT_STATE, action) => {
switch (action.type) {
case _UPDATE_ROOM_COUNTER:
return {
...state,
roomCounter: action.roomCounter
};
case UPDATE_BREAKOUT_ROOMS: {
const { nextIndex, rooms } = action;
const { roomCounter, rooms } = action;
return {
...state,
nextIndex,
roomCounter,
rooms
};
}

View File

@ -11,11 +11,6 @@
-- Component "breakout.jitmeet.example.com" "muc"
-- restrict_room_creation = true
-- storage = "memory"
-- modules_enabled = {
-- "muc_meeting_id";
-- "muc_domain_mapper";
-- --"token_verification";
-- }
-- admins = { "focusUser@auth.jitmeet.example.com" }
-- muc_room_locking = false
-- muc_room_default_public_jids = true
@ -161,6 +156,7 @@ function broadcast_breakout_rooms(room_jid)
local json_msg = json.encode({
type = BREAKOUT_ROOMS_IDENTITY_TYPE,
event = JSON_TYPE_UPDATE_BREAKOUT_ROOMS,
roomCounter = main_room._data.breakout_rooms_counter,
rooms = rooms
});
@ -192,7 +188,9 @@ function create_breakout_room(room_jid, subject)
if not main_room._data.breakout_rooms then
main_room._data.breakout_rooms = {};
main_room._data.breakout_rooms_counter = 0;
end
main_room._data.breakout_rooms_counter = main_room._data.breakout_rooms_counter + 1;
main_room._data.breakout_rooms[breakout_room_jid] = subject;
main_room._data.breakout_rooms_active = true;
-- Make room persistent - not to be destroyed - if all participants join breakout rooms.