Fix chat identity bug
This commit is contained in:
parent
ac7108c2c4
commit
43110f5356
1 changed files with 10 additions and 2 deletions
|
|
@ -103,12 +103,20 @@ export const chatsById = call(() => {
|
||||||
const chat = chatsById.get(chatId)
|
const chat = chatsById.get(chatId)
|
||||||
|
|
||||||
if (chat) {
|
if (chat) {
|
||||||
chat.messages = reject(spec({id: event.id}), chat.messages)
|
const messages = reject(spec({id: event.id}), chat.messages)
|
||||||
|
|
||||||
|
// Replace the chat with a fresh object rather than mutating its messages in place:
|
||||||
|
// deriveChat is deduplicated by reference (see makeDeriveItem/deriveDeduplicated), so a
|
||||||
|
// chat whose identity is unchanged never reaches the ui and the deleted message lingers
|
||||||
|
// on screen until some unrelated addEvents happens to rebuild it.
|
||||||
|
if (messages.length !== chat.messages.length) {
|
||||||
|
chatsById.set(chatId, {...chat, messages})
|
||||||
dirty = true
|
dirty = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (dirty) {
|
if (dirty) {
|
||||||
set(chatsById)
|
set(chatsById)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue