Fix conversation unread count overwritten
This commit is contained in:
parent
4fc46c40d4
commit
385137068f
1 changed files with 24 additions and 8 deletions
|
@ -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);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue