mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-01-17 11:28:06 +00:00
Prevents duplicated message when entering a conversation while SDK is still doing aggregation
This commit is contained in:
parent
9e3c679665
commit
54818c51b4
1 changed files with 22 additions and 1 deletions
|
|
@ -174,7 +174,28 @@ class ConversationViewModel @UiThread constructor() : AbstractConversationViewMo
|
|||
Log.i("$TAG Received [${eventLogs.size}] new message(s)")
|
||||
computeComposingLabel()
|
||||
|
||||
addEvents(eventLogs)
|
||||
// Prevents duplicates if user entered conversation while SDK was still doing messages aggregation
|
||||
val eventsToAdd = arrayListOf<EventLog>()
|
||||
for (event in eventLogs) {
|
||||
val found = eventsList.find {
|
||||
it.model is MessageModel && it.model.chatMessage.messageId == event.chatMessage?.messageId
|
||||
}
|
||||
if (found == null) {
|
||||
eventsToAdd.add(event)
|
||||
} else {
|
||||
Log.w(
|
||||
"$TAG Received message with ID [${event.chatMessage?.messageId}] is already displayed, do not add it again"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
if (eventsToAdd.size == eventLogs.size) {
|
||||
addEvents(eventLogs)
|
||||
} else {
|
||||
val eventsArray = arrayOf<EventLog>()
|
||||
eventsToAdd.toArray(eventsArray)
|
||||
addEvents(eventsArray)
|
||||
}
|
||||
|
||||
unreadMessagesCount.postValue(chatRoom.unreadMessagesCount)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue