ui: messagepad: merge current state and incoming payload (#312)

pull/315/head
pandadtdyy 3 years ago committed by GitHub
parent 1173407598
commit 723ad4951f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -4,10 +4,11 @@ export default function reducer(state = {}, action) {
switch (action.type) {
case 'DIALOGUES_LOAD_DIALOGUES_FULFILLED': {
const { messages } = action.payload;
return _.keyBy(messages, 'udoc._id');
return {...state, ..._.keyBy(messages, 'udoc._id')};
}
case 'DIALOGUES_CREATE': {
const { user } = action.payload;
if (state[user._id]) return state
return {
...state,
[user._id]: {

Loading…
Cancel
Save