Chats: sort messages properly

This commit is contained in:
Alex Gleason
2020-08-26 17:02:25 -05:00
parent 759c4ae4d0
commit 4b173f0580
2 changed files with 2 additions and 2 deletions

View File

@ -12,7 +12,7 @@ const mapStateToProps = (state, { chatMessageIds }) => ({
chatMessages: chatMessageIds.reduce((acc, curr) => {
const chatMessage = state.getIn(['chat_messages', curr]);
return chatMessage ? acc.push(chatMessage) : acc;
}, ImmutableList()),
}, ImmutableList()).sort(),
});
export default @connect(mapStateToProps)

View File

@ -28,7 +28,7 @@ export default function chatMessageLists(state = initialState, action) {
case CHAT_MESSAGES_IMPORT:
return importMessages(state, action.chatMessages);
case CHAT_MESSAGES_FETCH_SUCCESS:
return updateList(state, action.chatId, action.data.map(chat => chat.id));
return updateList(state, action.chatId, action.data.map(chat => chat.id).reverse());
case CHAT_MESSAGE_SEND_SUCCESS:
return updateList(state, action.chatId, [action.data.id]);
default: