2021-09-14 15:31:30 +00:00
|
|
|
// @flow
|
|
|
|
|
|
|
|
import { ReducerRegistry } from '../base/redux';
|
|
|
|
|
2021-11-25 11:43:42 +00:00
|
|
|
import {
|
2021-11-25 13:48:34 +00:00
|
|
|
_RESET_BREAKOUT_ROOMS,
|
2021-11-25 11:43:42 +00:00
|
|
|
_UPDATE_ROOM_COUNTER,
|
|
|
|
UPDATE_BREAKOUT_ROOMS
|
|
|
|
} from './actionTypes';
|
2021-09-14 15:31:30 +00:00
|
|
|
import { FEATURE_KEY } from './constants';
|
|
|
|
|
2021-11-25 11:43:42 +00:00
|
|
|
const DEFAULT_STATE = {
|
|
|
|
rooms: {},
|
|
|
|
roomCounter: 0
|
|
|
|
};
|
|
|
|
|
2021-09-14 15:31:30 +00:00
|
|
|
/**
|
|
|
|
* Listen for actions for the breakout-rooms feature.
|
|
|
|
*/
|
2021-11-25 11:43:42 +00:00
|
|
|
ReducerRegistry.register(FEATURE_KEY, (state = DEFAULT_STATE, action) => {
|
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;
|
|
|
|
});
|