Merge branch 'chats-dupe' into 'develop'

Chats: fix #451 duplicated message

Closes #451

See merge request soapbox-pub/soapbox-fe!279
config-ui-updates
Alex Gleason 2020-09-29 22:04:09 +00:00
commit 5e1d3421cf
2 zmienionych plików z 4 dodań i 4 usunięć

Wyświetl plik

@ -57,11 +57,13 @@ export function connectTimelineStream(timelineId, path, pollingRefresh = null, a
case 'pleroma:chat_update':
dispatch((dispatch, getState) => {
const chat = JSON.parse(data.payload);
const messageOwned = !(chat.last_message && chat.last_message.account_id !== getState().get('me'));
const me = getState().get('me');
const messageOwned = !(chat.last_message && chat.last_message.account_id !== me);
dispatch({
type: STREAMING_CHAT_UPDATE,
chat,
me,
// Only play sounds for recipient messages
meta: !messageOwned && getSettings(getState()).getIn(['chats', 'sound']) && { sound: 'chat' },
});

Wyświetl plik

@ -39,9 +39,7 @@ const importLastMessages = (state, chats) =>
}));
const replaceMessage = (state, chatId, oldId, newId) => {
const ids = state.get(chatId, ImmutableOrderedSet());
const newIds = ids.delete(oldId).add(newId).sort(idComparator);
return state.set(chatId, newIds);
return state.update(chatId, chat => chat.delete(oldId).add(newId).sort(idComparator));
};
export default function chatMessageLists(state = initialState, action) {