|
@@ -234,7 +234,11 @@ function msgReducer(state = {}, action) {
|
|
// обновить счетчик
|
|
// обновить счетчик
|
|
countMsgInChat(action.msg.chat._id);
|
|
countMsgInChat(action.msg.chat._id);
|
|
|
|
|
|
- return { ...state, ...{ [action.msg.chat._id]: [...state[action.msg.chat._id], newMsgItem] } };
|
|
|
|
|
|
+ if (state[action.msg.chat._id]) {
|
|
|
|
+ return { ...state, ...{ [action.msg.chat._id]: [...state[action.msg.chat._id], newMsgItem] } };
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return { ...state, ...{ [action.msg.chat._id]: newMsgItem } };
|
|
}
|
|
}
|
|
|
|
|
|
return state;
|
|
return state;
|
|
@@ -319,4 +323,4 @@ export const store = createStore(
|
|
applyMiddleware(thunk)
|
|
applyMiddleware(thunk)
|
|
);
|
|
);
|
|
|
|
|
|
-// store.subscribe(() => console.log(store.getState()));
|
|
|
|
|
|
+store.subscribe(() => console.log(store.getState()));
|