Fix conversation unread count overwritten

This commit is contained in:
Jamie Kyle 2023-11-28 14:53:43 -08:00 committed by GitHub
parent 4fc46c40d4
commit 385137068f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -894,17 +894,33 @@ async function saveCallHistory(
'callDisposition'
);
if (callHistory.direction === CallDirection.Outgoing) {
conversation.incrementSentMessageCount();
} else {
conversation.incrementMessageCount();
if (prevMessage == null) {
if (callHistory.direction === CallDirection.Outgoing) {
conversation.incrementSentMessageCount();
} else {
conversation.incrementMessageCount();
}
conversation.trigger('newmessage', model);
}
conversation.trigger('newmessage', model);
await conversation.updateLastMessage().catch(error => {
log.error(
'saveCallHistory: Failed to update last message:',
Errors.toLogFormat(error)
);
});
void conversation.updateLastMessage();
void conversation.updateUnread();
conversation.set('active_at', callHistory.timestamp);
await conversation.updateUnread().catch(error => {
log.error(
'saveCallHistory: Failed to update unread',
Errors.toLogFormat(error)
);
});
conversation.set(
'active_at',
Math.max(conversation.get('active_at') ?? 0, callHistory.timestamp)
);
if (canConversationBeUnarchived(conversation.attributes)) {
conversation.setArchived(false);