import { TActionsRoom } from '../actions/room';
import { ROOM } from '../actions/actionsTypes';
export type IRoomRecord = string[];
export interface IRoom {
rid: string;
isDeleting: boolean;
rooms: IRoomRecord;
}
export const initialState: IRoom = {
rid: '',
isDeleting: false,
rooms: []
};
export default function (state = initialState, action: TActionsRoom): IRoom {
switch (action.type) {
case ROOM.SUBSCRIBE:
return {
...state,
rooms: [action.rid, ...state.rooms]
case ROOM.UNSUBSCRIBE:
rooms: state.rooms.filter(rid => rid !== action.rid)
case ROOM.LEAVE:
rid: action.room.rid,
isDeleting: true
case ROOM.DELETE:
case ROOM.CLOSE:
rid: action.rid,
case ROOM.FORWARD:
case ROOM.REMOVED:
isDeleting: false
default:
return state;