Skip to content
Snippets Groups Projects
Commit 78e5a639 authored by Eugenij's avatar Eugenij Committed by Eugenij
Browse files

Apply 1 suggestion(s) to 1 file(s)

parent e798e9a4
No related branches found
No related tags found
2 merge requests!1278Merge develop into master for 2.2.0,!1228Optimistic / nonblocking message posting for chats
......@@ -78,6 +78,12 @@ const add = (storage, { messages: newMessages, updateMaxId = true }) => {
if (message.fakeId) {
const fakeMessage = storage.idIndex[message.fakeId]
if (fakeMessage) {
// In case the same id exists (chat update before POST response)
// make sure to remove the older duplicate message.
if (storage.idIndex[message.id]) {
delete storage.idIndex[message.id]
storage.messages = storage.messages.filter(msg => msg.id !== message.id)
}
Object.assign(fakeMessage, message, { error: false })
delete fakeMessage['fakeId']
storage.idIndex[fakeMessage.id] = fakeMessage
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment