pleroma/app/soapbox/reducers/chats.js
2020-08-24 21:26:42 -05:00

15 lines
430 B
JavaScript

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;
}
};