Skip to content
Snippets Groups Projects
Verified Commit 1c0bc5e0 authored by Janne Mareike Koschinski's avatar Janne Mareike Koschinski
Browse files

Fixes #186

parent fb888db2
No related branches found
No related tags found
No related merge requests found
......@@ -394,6 +394,16 @@ class QuasselViewModel : ViewModel() {
activity to highlights
}
}.switchMap { (activity, highlights) ->
val name = info.bufferName?.trim() ?: ""
val search = bufferSearch.trim()
val matchMode = when {
name.equals(search, ignoreCase = true) ->
BufferProps.BufferMatchMode.EXACT
name.startsWith(search, ignoreCase = true) ->
BufferProps.BufferMatchMode.START
else ->
BufferProps.BufferMatchMode.CONTAINS
}
when (info.type.toInt()) {
BufferInfo.Type.QueryBuffer.toInt() -> {
network.liveNetworkInfo().switchMap { networkInfo ->
......@@ -413,7 +423,8 @@ class QuasselViewModel : ViewModel() {
activity = activity,
highlights = highlights,
hiddenState = state,
ircUser = user
ircUser = user,
matchMode = matchMode
)
}
}
......@@ -436,7 +447,8 @@ class QuasselViewModel : ViewModel() {
description = it?.topic() ?: "",
activity = activity,
highlights = highlights,
hiddenState = state
hiddenState = state,
matchMode = matchMode
)
}
}
......@@ -454,7 +466,8 @@ class QuasselViewModel : ViewModel() {
description = "",
activity = activity,
highlights = highlights,
hiddenState = state
hiddenState = state,
matchMode = matchMode
)
}
}
......@@ -536,6 +549,7 @@ class QuasselViewModel : ViewModel() {
}.let {
if (config.sortAlphabetically())
it.sortedBy { IrcCaseMappers.unicode.toLowerCaseNullable(it.info.bufferName) }
.sortedBy { it.matchMode.priority }
.sortedByDescending { it.hiddenState == BufferHiddenState.VISIBLE }
else it
}.distinctBy {
......
......@@ -40,8 +40,15 @@ data class BufferProps(
val hiddenState: BufferHiddenState,
val ircUser: IrcUser? = null,
val avatarUrls: List<Avatar> = emptyList(),
val fallbackDrawable: Drawable? = null
val fallbackDrawable: Drawable? = null,
val matchMode: BufferMatchMode = BufferMatchMode.EXACT
) {
enum class BufferMatchMode(val priority: Int) {
EXACT(0),
START(1),
CONTAINS(2);
}
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (javaClass != other?.javaClass) return false
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment