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' 'callDisposition'
); );
if (callHistory.direction === CallDirection.Outgoing) { if (prevMessage == null) {
conversation.incrementSentMessageCount(); if (callHistory.direction === CallDirection.Outgoing) {
} else { conversation.incrementSentMessageCount();
conversation.incrementMessageCount(); } 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(); await conversation.updateUnread().catch(error => {
void conversation.updateUnread(); log.error(
conversation.set('active_at', callHistory.timestamp); '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)) { if (canConversationBeUnarchived(conversation.attributes)) {
conversation.setArchived(false); conversation.setArchived(false);