Display existing group members in alphabetical order on add to groups screen.

This commit is contained in:
jeffrey-signal
2025-11-26 16:13:17 -05:00
parent 002d70496f
commit f4c246eef0

View File

@@ -576,14 +576,19 @@ open class ContactSearchAdapter(
if (getRecipient(model).isGroup) {
number.text = getRecipient(model).participantIds
.take(10)
.map { id -> Recipient.resolved(id) }
.sortedWith(IsSelfComparator()).joinToString(", ") {
if (it.isSelf) {
context.getString(R.string.ConversationTitleView_you)
} else {
it.getShortDisplayName(context)
}
.map { id ->
val recipient = Recipient.resolved(id)
RecipientDisplayName(
recipient = recipient,
displayName = if (recipient.isSelf) {
context.getString(R.string.ConversationTitleView_you)
} else {
recipient.getShortDisplayName(context)
}
)
}
.sortedWith(compareBy({ it.recipient.isSelf }, { it.displayName }))
.joinToString(", ") { it.displayName }
}
}
@@ -761,21 +766,6 @@ open class ContactSearchAdapter(
}
}
private class IsSelfComparator : Comparator<Recipient> {
override fun compare(lhs: Recipient?, rhs: Recipient?): Int {
val isLeftSelf = lhs?.isSelf == true
val isRightSelf = rhs?.isSelf == true
return if (isLeftSelf == isRightSelf) {
0
} else if (isLeftSelf) {
1
} else {
-1
}
}
}
interface StoryContextMenuCallbacks {
fun onOpenStorySettings(story: ContactSearchData.Story)
fun onRemoveGroupStory(story: ContactSearchData.Story, isSelected: Boolean)
@@ -813,6 +803,7 @@ open class ContactSearchAdapter(
fun onUnknownRecipientClicked(view: View, unknownRecipient: ContactSearchData.UnknownRecipient, isSelected: Boolean) {
throw NotImplementedError()
}
fun onChatTypeClicked(view: View, chatTypeRow: ContactSearchData.ChatTypeRow, isSelected: Boolean)
}
@@ -834,3 +825,5 @@ open class ContactSearchAdapter(
override fun onKnownRecipientLongClick(view: View, data: ContactSearchData.KnownRecipient): Boolean = false
}
}
private data class RecipientDisplayName(val recipient: Recipient, val displayName: String)