@@ -163,11 +163,11 @@ class MentionViewModel(
163
163
true
164
164
)
165
165
166
- // Other members from this groupv2
166
+ // Get other members
167
167
val otherMembers = if (recipient.isGroupV2Recipient) {
168
168
val groupId = AccountId (recipient.address.toString())
169
169
170
- // Get members of the group
170
+ // Get members of the group from the config
171
171
val rawMembers = configFactory.withGroupConfigs(groupId) {
172
172
it.groupMembers.allWithStatus()
173
173
}
@@ -183,12 +183,16 @@ class MentionViewModel(
183
183
) // returns contact name or blank
184
184
.takeIf { it.isNotBlank() } ? : id // fallback to id
185
185
buildMember(id, name, id in moderatorIDs, false )
186
- }
186
+ }.sortedBy { it.name }
187
187
} else {
188
- // Fallback to only local contacts
189
- contactDatabase.getContacts(memberIDs)
190
- .asSequence()
191
- .filter { it.accountID != myId }
188
+ // For communities and one-on-one conversations
189
+ val contacts = contactDatabase.getContacts(memberIDs) // Get members from contacts based on memberIDs
190
+ val contactMap = contacts.associateBy { it.accountID }
191
+
192
+ // Map using memberIDs to preserve the order of members
193
+ memberIDs.asSequence()
194
+ .filter { it != myId }
195
+ .mapNotNull { contactMap[it] }
192
196
.map { contact ->
193
197
val id = contact.accountID
194
198
val name = contact.displayName(contactContext)
@@ -348,7 +352,6 @@ class MentionViewModel(
348
352
companion object {
349
353
val MENTION_LIST_COMPARATOR = compareBy<Candidate > { ! it.member.isMe }
350
354
.thenBy { it.matchScore }
351
- .then(compareBy { it.member.name })
352
355
}
353
356
}
354
357
0 commit comments