2020-03-06 13:13:24 +00:00
|
|
|
import { ROOM } from '../actions/actionsTypes';
|
|
|
|
|
|
|
|
const initialState = {
|
|
|
|
rid: null,
|
2020-04-30 17:53:35 +00:00
|
|
|
isDeleting: false,
|
|
|
|
rooms: []
|
2020-03-06 13:13:24 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
export default function(state = initialState, action) {
|
|
|
|
switch (action.type) {
|
2020-04-30 17:53:35 +00:00
|
|
|
case ROOM.SUBSCRIBE:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
rooms: [action.rid, ...state.rooms]
|
|
|
|
};
|
|
|
|
case ROOM.UNSUBSCRIBE:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
rooms: state.rooms
|
2020-06-15 14:00:46 +00:00
|
|
|
.filter(rid => rid !== action.rid)
|
2020-04-30 17:53:35 +00:00
|
|
|
};
|
2020-03-20 16:38:01 +00:00
|
|
|
case ROOM.LEAVE:
|
2020-03-06 13:13:24 +00:00
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
rid: action.rid,
|
|
|
|
isDeleting: true
|
|
|
|
};
|
2020-03-20 16:38:01 +00:00
|
|
|
case ROOM.DELETE:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
rid: action.rid,
|
|
|
|
isDeleting: true
|
|
|
|
};
|
2020-05-08 17:36:10 +00:00
|
|
|
case ROOM.CLOSE:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
rid: action.rid,
|
|
|
|
isDeleting: true
|
|
|
|
};
|
|
|
|
case ROOM.FORWARD:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
rid: action.rid,
|
|
|
|
isDeleting: true
|
|
|
|
};
|
2020-03-20 16:38:01 +00:00
|
|
|
case ROOM.REMOVED:
|
2020-03-06 13:13:24 +00:00
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
isDeleting: false
|
|
|
|
};
|
|
|
|
default:
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
}
|