Skip to content

Commit d55ecda

Browse files
committed
Fix displaying chats by lastMessageDate
When new message received or created, the newest chats didn't go to first position
1 parent 8ba797b commit d55ecda

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/reducers/chats-reducer.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,8 @@ export default (state = initialState, { type, payload }) => {
102102
date: new Date().toISOString(),
103103
isSending: true,
104104
};
105-
// console.log(newMessage);
106105
updatedChat.messages.push(newMessage);
106+
updatedChat.lastMessageDate = new Date().toISOString();
107107
const updatedChats = [...state.chats];
108108
updatedChats[chatIndex] = updatedChat;
109109
return {
@@ -158,6 +158,7 @@ export default (state = initialState, { type, payload }) => {
158158
JSON.stringify(state.chats[conversationIndex])
159159
);
160160
newConversation.messages.push(newMessage);
161+
newConversation.lastMessageDate = newMessage.date;
161162
newChats[conversationIndex] = newConversation;
162163
return {
163164
...state,

0 commit comments

Comments
 (0)