pleroma/app/soapbox/reducers/chats.js

16 lines
430 B
JavaScript
Raw Normal View History

2020-08-24 19:26:42 -07:00
import { CHATS_FETCH_SUCCESS } from '../actions/chats';
import { Map as ImmutableMap, fromJS } from 'immutable';
const initialState = ImmutableMap();
export default function admin(state = initialState, action) {
switch(action.type) {
case CHATS_FETCH_SUCCESS:
return state.merge(fromJS(action.data).reduce((acc, curr) => (
acc.set(curr.get('id'), curr)
), ImmutableMap()));
default:
return state;
}
};