2022-09-30 14:50:45 +00:00
|
|
|
import ReducerRegistry from '../base/redux/ReducerRegistry';
|
|
|
|
|
|
|
|
import { RESET_WHITEBOARD, SETUP_WHITEBOARD } from './actionTypes';
|
|
|
|
|
|
|
|
export interface IWhiteboardState {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The whiteboard collaboration details.
|
|
|
|
*/
|
|
|
|
collabDetails?: { roomId: string; roomKey: string; };
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The indicator which determines whether the whiteboard is open.
|
|
|
|
*
|
|
|
|
* @type {boolean}
|
|
|
|
*/
|
|
|
|
isOpen: boolean;
|
|
|
|
}
|
|
|
|
|
|
|
|
const DEFAULT_STATE: IWhiteboardState = {
|
|
|
|
isOpen: false
|
|
|
|
};
|
|
|
|
|
2022-10-20 09:11:27 +00:00
|
|
|
export interface IWhiteboardAction extends Partial<IWhiteboardState> {
|
2022-09-30 14:50:45 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The whiteboard collaboration details.
|
|
|
|
*/
|
|
|
|
collabDetails?: { roomId: string; roomKey: string; };
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The action type.
|
|
|
|
*/
|
|
|
|
type: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
ReducerRegistry.register(
|
|
|
|
'features/whiteboard',
|
2022-10-20 09:11:27 +00:00
|
|
|
(state: IWhiteboardState = DEFAULT_STATE, action: IWhiteboardAction) => {
|
2022-09-30 14:50:45 +00:00
|
|
|
switch (action.type) {
|
|
|
|
case SETUP_WHITEBOARD: {
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
isOpen: true,
|
|
|
|
collabDetails: action.collabDetails
|
|
|
|
};
|
|
|
|
}
|
|
|
|
case RESET_WHITEBOARD:
|
|
|
|
return DEFAULT_STATE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return state;
|
|
|
|
});
|