mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2025-06-28 20:29:53 +00:00
android, desktop: fix group members duplicates (#5727)
* android, desktop: fix group members duplicates * optimization * use groupMemberId as key --------- Co-authored-by: Evgeny Poberezkin <evgeny@poberezkin.com>
This commit is contained in:
parent
27f63dafaa
commit
3412ceba01
2 changed files with 6 additions and 1 deletions
|
@ -789,6 +789,11 @@ object ChatModel {
|
||||||
}
|
}
|
||||||
// update current chat
|
// update current chat
|
||||||
return if (chatId.value == groupInfo.id) {
|
return if (chatId.value == groupInfo.id) {
|
||||||
|
if (groupMembers.value.isNotEmpty() && groupMembers.value.firstOrNull()?.groupId != groupInfo.groupId) {
|
||||||
|
// stale data, should be cleared at that point, otherwise, duplicated items will be here which will produce crashes in LazyColumn
|
||||||
|
groupMembers.value = emptyList()
|
||||||
|
groupMembersIndexes.value = emptyMap()
|
||||||
|
}
|
||||||
val memberIndex = groupMembersIndexes.value[member.groupMemberId]
|
val memberIndex = groupMembersIndexes.value[member.groupMemberId]
|
||||||
val updated = chatItems.value.map {
|
val updated = chatItems.value.map {
|
||||||
// Take into account only specific changes, not all. Other member updates are not important and can be skipped
|
// Take into account only specific changes, not all. Other member updates are not important and can be skipped
|
||||||
|
|
|
@ -196,7 +196,7 @@ fun GroupMentions(
|
||||||
MaxMentionsReached()
|
MaxMentionsReached()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
itemsIndexed(filteredMembers.value, key = { _, item -> item.memberId }) { i, member ->
|
itemsIndexed(filteredMembers.value, key = { _, item -> item.groupMemberId }) { i, member ->
|
||||||
if (i != 0 || !showMaxReachedBox) {
|
if (i != 0 || !showMaxReachedBox) {
|
||||||
Divider()
|
Divider()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue