66 */
77package com.nextcloud.talk.conversationlist.viewmodels
88
9+ import android.annotation.SuppressLint
910import android.content.Context
1011import android.util.Log
11- import androidx.compose.ui.text.intl.Locale
12- import androidx.compose.ui.text.toLowerCase
1312import androidx.lifecycle.LiveData
1413import androidx.lifecycle.MutableLiveData
1514import androidx.lifecycle.ViewModel
@@ -302,6 +301,7 @@ class ConversationsListViewModel @Inject constructor(
302301 }
303302 }
304303
304+ @SuppressLint(" DefaultLocale" )
305305 @Suppress(" LongMethod" )
306306 fun getSearchQuery (context : Context , filter : String ) {
307307 // Rotation / display-off guard: if the composition restarts (config change) the
@@ -388,7 +388,7 @@ class ConversationsListViewModel @Inject constructor(
388388 processOrderAndAdd(
389389 messages,
390390 firstPredicate = {
391- it.messageExcerpt.toLowerCase( Locale .current). contains(pattern)
391+ it.messageExcerpt.contains(pattern)
392392 },
393393 addAction = { msg -> entries.add(ConversationListEntry .MessageResultEntry (msg)) }
394394 )
@@ -403,7 +403,7 @@ class ConversationsListViewModel @Inject constructor(
403403 }
404404 }
405405
406- // I made this function to order any arbitrary list according to
406+ // This function orders any arbitrary list according to
407407 // [meets predicate 1][meets predicate 2]?[the rest]
408408 // and applying a unit function upon the result of these reorderings
409409 private fun <T > processOrderAndAdd (
@@ -414,25 +414,19 @@ class ConversationsListViewModel @Inject constructor(
414414 ) {
415415 val result = mutableListOf<T >()
416416
417- val (firstPredicate, remainingFirst) = list.split (firstPredicate)
417+ val (firstPredicate, remainingFirst) = list.partition (firstPredicate)
418418 result.addAll(firstPredicate)
419419
420- secondPredicate?. let {
421- val (secondPredicate, remainingSecond) = remainingFirst.split (secondPredicate)
420+ if ( secondPredicate != null ) {
421+ val (secondPredicate, remainingSecond) = remainingFirst.partition (secondPredicate)
422422 result.addAll(secondPredicate + remainingSecond)
423- } ? : {
423+ } else {
424424 result.addAll(remainingFirst)
425425 }
426426
427427 result.forEach(addAction)
428428 }
429429
430- private inline fun <T > Iterable<T>.split (predicate : (T ) -> Boolean ): Pair <List <T >, List<T>> =
431- Pair (
432- this .filter(predicate),
433- this .filterNot(predicate)
434- )
435-
436430 private fun getMessagesFlow (search : String ): Flow <MessageSearchResults > =
437431 flow {
438432 emit(searchHelper.startMessageSearch(search))
0 commit comments