2022-08-26 09:54:16 +00:00
|
|
|
import ReducerRegistry from '../base/redux/ReducerRegistry';
|
2021-04-21 13:48:05 +00:00
|
|
|
|
|
|
|
import {
|
|
|
|
PARTICIPANTS_PANE_CLOSE,
|
2021-07-01 10:12:38 +00:00
|
|
|
PARTICIPANTS_PANE_OPEN,
|
|
|
|
SET_VOLUME
|
2021-04-21 13:48:05 +00:00
|
|
|
} from './actionTypes';
|
|
|
|
import { REDUCER_KEY } from './constants';
|
|
|
|
|
2022-09-14 11:32:58 +00:00
|
|
|
export interface IParticipantsPaneState {
|
2022-08-26 09:54:16 +00:00
|
|
|
isOpen: boolean;
|
|
|
|
participantsVolume: {
|
|
|
|
[participantId: string]: number;
|
2022-09-08 09:52:36 +00:00
|
|
|
};
|
2022-08-26 09:54:16 +00:00
|
|
|
}
|
|
|
|
|
2021-04-21 13:48:05 +00:00
|
|
|
const DEFAULT_STATE = {
|
2021-07-01 10:12:38 +00:00
|
|
|
isOpen: false,
|
|
|
|
participantsVolume: {}
|
2021-04-21 13:48:05 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2021-11-04 21:10:43 +00:00
|
|
|
* Listen for actions that mutate the participants pane state.
|
2021-04-21 13:48:05 +00:00
|
|
|
*/
|
|
|
|
ReducerRegistry.register(
|
2022-09-14 11:32:58 +00:00
|
|
|
REDUCER_KEY, (state: IParticipantsPaneState = DEFAULT_STATE, action) => {
|
2021-04-21 13:48:05 +00:00
|
|
|
switch (action.type) {
|
|
|
|
case PARTICIPANTS_PANE_CLOSE:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
isOpen: false
|
|
|
|
};
|
|
|
|
|
|
|
|
case PARTICIPANTS_PANE_OPEN:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
isOpen: true
|
|
|
|
};
|
|
|
|
|
2021-07-01 10:12:38 +00:00
|
|
|
case SET_VOLUME:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
participantsVolume: {
|
|
|
|
...state.participantsVolume,
|
|
|
|
|
|
|
|
[action.participantId]: action.volume
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-04-21 13:48:05 +00:00
|
|
|
default:
|
|
|
|
return state;
|
|
|
|
}
|
2021-11-04 21:10:43 +00:00
|
|
|
}
|
2021-04-21 13:48:05 +00:00
|
|
|
);
|