Chats: fix flickering during update

This commit is contained in:
Alex Gleason 2020-08-27 00:24:11 -05:00
parent 9af664bda8
commit 8b621d30fc
No known key found for this signature in database
GPG key ID: 7211D1F99744FBB7
2 changed files with 5 additions and 4 deletions

View file

@ -55,7 +55,7 @@ export function connectTimelineStream(timelineId, path, pollingRefresh = null, a
dispatch(fetchFilters());
break;
case 'pleroma:chat_update':
dispatch({ type: STREAMING_CHAT_UPDATE, chat: JSON.parse(data.payload) });
dispatch({ type: STREAMING_CHAT_UPDATE, chat: JSON.parse(data.payload), me: getState().get('me') });
break;
}
},

View file

@ -38,15 +38,16 @@ export default function chatMessageLists(state = initialState, action) {
case CHATS_FETCH_SUCCESS:
return importLastMessages(state, action.chats).sort();
case STREAMING_CHAT_UPDATE:
if (action.chat.last_message)
if (action.chat.last_message &&
action.chat.last_message.account_id !== action.me)
return importMessages(state, [action.chat.last_message]).sort();
else
return state.sort();
return state;
case CHAT_MESSAGES_FETCH_SUCCESS:
return updateList(state, action.chatId, action.chatMessages.map(chat => chat.id).reverse()).sort();
case CHAT_MESSAGE_SEND_SUCCESS:
return updateList(state, action.chatId, [action.chatMessage.id]).sort();
default:
return state.sort();
return state;
}
};