sforkowany z mirror/soapbox
Fix chat submission
rodzic
ecefab9956
commit
759c4ae4d0
|
@ -9,7 +9,10 @@ import emojify from 'soapbox/features/emoji/emoji';
|
||||||
|
|
||||||
const mapStateToProps = (state, { chatMessageIds }) => ({
|
const mapStateToProps = (state, { chatMessageIds }) => ({
|
||||||
me: state.get('me'),
|
me: state.get('me'),
|
||||||
chatMessages: chatMessageIds.map(id => state.getIn(['chat_messages', id])).toList(),
|
chatMessages: chatMessageIds.reduce((acc, curr) => {
|
||||||
|
const chatMessage = state.getIn(['chat_messages', curr]);
|
||||||
|
return chatMessage ? acc.push(chatMessage) : acc;
|
||||||
|
}, ImmutableList()),
|
||||||
});
|
});
|
||||||
|
|
||||||
export default @connect(mapStateToProps)
|
export default @connect(mapStateToProps)
|
||||||
|
|
|
@ -8,7 +8,8 @@ import { Map as ImmutableMap, OrderedSet as ImmutableOrderedSet } from 'immutabl
|
||||||
const initialState = ImmutableMap();
|
const initialState = ImmutableMap();
|
||||||
|
|
||||||
const updateList = (state, chatId, messageIds) => {
|
const updateList = (state, chatId, messageIds) => {
|
||||||
const newIds = state.get(chatId, ImmutableOrderedSet()).union(messageIds);
|
const ids = state.get(chatId, ImmutableOrderedSet());
|
||||||
|
const newIds = ids.union(messageIds);
|
||||||
return state.set(chatId, newIds);
|
return state.set(chatId, newIds);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -29,7 +30,7 @@ export default function chatMessageLists(state = initialState, action) {
|
||||||
case CHAT_MESSAGES_FETCH_SUCCESS:
|
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));
|
||||||
case CHAT_MESSAGE_SEND_SUCCESS:
|
case CHAT_MESSAGE_SEND_SUCCESS:
|
||||||
return updateList(state, action.chatId, action.data.id);
|
return updateList(state, action.chatId, [action.data.id]);
|
||||||
default:
|
default:
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
Ładowanie…
Reference in New Issue