2022-08-08 11:06:29 +00:00
|
|
|
import ReducerRegistry from '../base/redux/ReducerRegistry';
|
2021-09-14 15:31:30 +00:00
|
|
|
|
2021-11-25 11:43:42 +00:00
|
|
|
import {
|
2022-09-27 07:10:28 +00:00
|
|
|
UPDATE_BREAKOUT_ROOMS,
|
2021-11-25 13:48:34 +00:00
|
|
|
_RESET_BREAKOUT_ROOMS,
|
2022-09-27 07:10:28 +00:00
|
|
|
_UPDATE_ROOM_COUNTER
|
2021-11-25 11:43:42 +00:00
|
|
|
} from './actionTypes';
|
2021-09-14 15:31:30 +00:00
|
|
|
import { FEATURE_KEY } from './constants';
|
2022-09-14 11:32:58 +00:00
|
|
|
import { IRooms } from './types';
|
2021-09-14 15:31:30 +00:00
|
|
|
|
2021-11-25 11:43:42 +00:00
|
|
|
const DEFAULT_STATE = {
|
|
|
|
rooms: {},
|
|
|
|
roomCounter: 0
|
|
|
|
};
|
|
|
|
|
2022-08-08 11:06:29 +00:00
|
|
|
export interface IBreakoutRoomsState {
|
|
|
|
roomCounter: number;
|
2022-09-14 11:32:58 +00:00
|
|
|
rooms: IRooms;
|
2022-08-08 11:06:29 +00:00
|
|
|
}
|
|
|
|
|
2021-09-14 15:31:30 +00:00
|
|
|
/**
|
|
|
|
* Listen for actions for the breakout-rooms feature.
|
|
|
|
*/
|
2022-09-05 09:05:07 +00:00
|
|
|
ReducerRegistry.register<IBreakoutRoomsState>(FEATURE_KEY, (state = DEFAULT_STATE, action): IBreakoutRoomsState => {
|
2021-09-14 15:31:30 +00:00
|
|
|
switch (action.type) {
|
2021-11-25 11:43:42 +00:00
|
|
|
case _UPDATE_ROOM_COUNTER:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
roomCounter: action.roomCounter
|
|
|
|
};
|
2021-09-14 15:31:30 +00:00
|
|
|
case UPDATE_BREAKOUT_ROOMS: {
|
2021-11-25 11:43:42 +00:00
|
|
|
const { roomCounter, rooms } = action;
|
2021-09-14 15:31:30 +00:00
|
|
|
|
|
|
|
return {
|
|
|
|
...state,
|
2021-11-25 11:43:42 +00:00
|
|
|
roomCounter,
|
2021-09-14 15:31:30 +00:00
|
|
|
rooms
|
|
|
|
};
|
|
|
|
}
|
2021-11-25 13:48:34 +00:00
|
|
|
case _RESET_BREAKOUT_ROOMS: {
|
|
|
|
return DEFAULT_STATE;
|
|
|
|
}
|
2021-09-14 15:31:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return state;
|
|
|
|
});
|