pleroma/app/soapbox/reducers/chats.js
2020-08-25 12:38:21 -05:00

20 lines
611 B
JavaScript

import { CHAT_IMPORT, CHATS_IMPORT } from 'soapbox/actions/importer';
import { Map as ImmutableMap, fromJS } from 'immutable';
const importChat = (state, chat) => state.set(chat.id, fromJS(chat));
const importChats = (state, chats) =>
state.withMutations(mutable => chats.forEach(chat => importChat(mutable, chat)));
const initialState = ImmutableMap();
export default function admin(state = initialState, action) {
switch(action.type) {
case CHAT_IMPORT:
return importChat(state, action.chat);
case CHATS_IMPORT:
return importChats(state, action.chats);
default:
return state;
}
};