@@ -8,6 +8,7 @@ import kotlinx.coroutines.Dispatchers
88import kotlinx.coroutines.ExperimentalCoroutinesApi
99import kotlinx.coroutines.flow.Flow
1010import kotlinx.coroutines.flow.MutableStateFlow
11+ import kotlinx.coroutines.flow.SharedFlow
1112import kotlinx.coroutines.flow.SharingStarted
1213import kotlinx.coroutines.flow.combine
1314import kotlinx.coroutines.flow.debounce
@@ -21,10 +22,7 @@ import org.session.libsignal.utilities.Log
2122import org.thoughtcrime.securesms.database.ThreadDatabase
2223import org.thoughtcrime.securesms.dependencies.ConfigFactory
2324import org.thoughtcrime.securesms.search.SearchRepository
24- import org.thoughtcrime.securesms.search.model.SearchResult
2525import javax.inject.Inject
26- import kotlin.coroutines.resume
27- import kotlin.coroutines.suspendCoroutine
2826
2927@OptIn(ExperimentalCoroutinesApi ::class )
3028@HiltViewModel
@@ -45,9 +43,9 @@ class GlobalSearchViewModel @Inject constructor(
4543 configFactory.configUpdateNotifications
4644 )
4745
48- val noteToSelfString by lazy { application.getString(R .string.noteToSelf).lowercase() }
46+ val noteToSelfString: String by lazy { application.getString(R .string.noteToSelf).lowercase() }
4947
50- val result = combine(
48+ val result: SharedFlow < GlobalSearchResult > = combine(
5149 _queryText ,
5250 observeChangesAffectingSearch().onStart { emit(Unit ) }
5351 ) { query, _ -> query }
@@ -64,7 +62,7 @@ class GlobalSearchViewModel @Inject constructor(
6462 )
6563 }
6664 } else {
67- val results = searchRepository.suspendQuery (query).toGlobalSearchResult()
65+ val results = searchRepository.query (query).toGlobalSearchResult()
6866
6967 // show "Note to Self" is the user searches for parts of"Note to Self"
7068 if (noteToSelfString.contains(query.lowercase())){
@@ -85,8 +83,3 @@ class GlobalSearchViewModel @Inject constructor(
8583 }
8684}
8785
88- private suspend fun SearchRepository.suspendQuery (query : String ): SearchResult {
89- return suspendCoroutine { cont ->
90- query(query, cont::resume)
91- }
92- }
0 commit comments