Skip to content

Commit 4205dd5

Browse files
committed
Match score sorting
1 parent 72c49aa commit 4205dd5

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

app/src/main/java/org/thoughtcrime/securesms/conversation/v2/mention/MentionViewModel.kt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@ class MentionViewModel(
232232
}
233233
}
234234

235+
filtered.sortWith(Candidate.MENTION_LIST_COMPARATOR)
235236
AutoCompleteState.Result(filtered, query.query)
236237
}
237238
}
@@ -347,7 +348,12 @@ class MentionViewModel(
347348
val nameHighlighted: CharSequence,
348349
// The score of matching the query keyword. Lower is better.
349350
val matchScore: Int,
350-
)
351+
) {
352+
companion object {
353+
val MENTION_LIST_COMPARATOR = compareBy<Candidate> { !it.member.isMe }
354+
.thenBy { it.matchScore }
355+
}
356+
}
351357

352358
sealed interface AutoCompleteState {
353359
object Idle : AutoCompleteState

0 commit comments

Comments
 (0)