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() { ...@@ -394,6 +394,16 @@ class QuasselViewModel : ViewModel() {
activity to highlights activity to highlights
} }
}.switchMap { (activity, 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()) { when (info.type.toInt()) {
BufferInfo.Type.QueryBuffer.toInt() -> { BufferInfo.Type.QueryBuffer.toInt() -> {
network.liveNetworkInfo().switchMap { networkInfo -> network.liveNetworkInfo().switchMap { networkInfo ->
...@@ -413,7 +423,8 @@ class QuasselViewModel : ViewModel() { ...@@ -413,7 +423,8 @@ class QuasselViewModel : ViewModel() {
activity = activity, activity = activity,
highlights = highlights, highlights = highlights,
hiddenState = state, hiddenState = state,
ircUser = user ircUser = user,
matchMode = matchMode
) )
} }
} }
...@@ -436,7 +447,8 @@ class QuasselViewModel : ViewModel() { ...@@ -436,7 +447,8 @@ class QuasselViewModel : ViewModel() {
description = it?.topic() ?: "", description = it?.topic() ?: "",
activity = activity, activity = activity,
highlights = highlights, highlights = highlights,
hiddenState = state hiddenState = state,
matchMode = matchMode
) )
} }
} }
...@@ -454,7 +466,8 @@ class QuasselViewModel : ViewModel() { ...@@ -454,7 +466,8 @@ class QuasselViewModel : ViewModel() {
description = "", description = "",
activity = activity, activity = activity,
highlights = highlights, highlights = highlights,
hiddenState = state hiddenState = state,
matchMode = matchMode
) )
} }
} }
...@@ -536,6 +549,7 @@ class QuasselViewModel : ViewModel() { ...@@ -536,6 +549,7 @@ class QuasselViewModel : ViewModel() {
}.let { }.let {
if (config.sortAlphabetically()) if (config.sortAlphabetically())
it.sortedBy { IrcCaseMappers.unicode.toLowerCaseNullable(it.info.bufferName) } it.sortedBy { IrcCaseMappers.unicode.toLowerCaseNullable(it.info.bufferName) }
.sortedBy { it.matchMode.priority }
.sortedByDescending { it.hiddenState == BufferHiddenState.VISIBLE } .sortedByDescending { it.hiddenState == BufferHiddenState.VISIBLE }
else it else it
}.distinctBy { }.distinctBy {
......
...@@ -40,8 +40,15 @@ data class BufferProps( ...@@ -40,8 +40,15 @@ data class BufferProps(
val hiddenState: BufferHiddenState, val hiddenState: BufferHiddenState,
val ircUser: IrcUser? = null, val ircUser: IrcUser? = null,
val avatarUrls: List<Avatar> = emptyList(), 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 { override fun equals(other: Any?): Boolean {
if (this === other) return true if (this === other) return true
if (javaClass != other?.javaClass) return false 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