mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
fix kotlin string concat error. clear cursor value when search term changes
This commit is contained in:
parent
c952dd0686
commit
357faf5947
1 changed files with 7 additions and 3 deletions
|
|
@ -48,6 +48,10 @@ class HomeViewModel @Inject constructor(
|
|||
}
|
||||
|
||||
fun load(clearPreviousSearch: Boolean = false) {
|
||||
if (clearPreviousSearch) {
|
||||
cursor = null
|
||||
}
|
||||
|
||||
viewModelScope.launch {
|
||||
val thisSearchIdx = searchIdx
|
||||
searchIdx += 1
|
||||
|
|
@ -66,20 +70,20 @@ class HomeViewModel @Inject constructor(
|
|||
)
|
||||
).execute()
|
||||
|
||||
|
||||
// Search results aren't guaranteed to return in order so this
|
||||
// will discard old results that are returned while a user is typing.
|
||||
// For example if a user types 'Canucks', often the search results
|
||||
// for 'C' are returned after 'Canucks' because it takes the backend
|
||||
// much longer to compute.
|
||||
if (thisSearchIdx in 1..receivedIdx) {
|
||||
Log.d("loggo", "early return from load function")
|
||||
return@launch
|
||||
}
|
||||
|
||||
cursor = response.data?.search?.onSearchSuccess?.pageInfo?.endCursor
|
||||
receivedIdx = thisSearchIdx
|
||||
val itemList = response.data?.search?.onSearchSuccess?.edges ?: listOf()
|
||||
|
||||
|
||||
val newItems = itemList.map {
|
||||
LinkedItem(
|
||||
id = it.node.id,
|
||||
|
|
@ -111,7 +115,7 @@ class HomeViewModel @Inject constructor(
|
|||
var query = "in:inbox sort:saved"
|
||||
|
||||
if (searchTextLiveData.value != "") {
|
||||
query.plus(" ${searchTextLiveData.value}")
|
||||
query = query.plus(" ${searchTextLiveData.value}")
|
||||
}
|
||||
|
||||
return query
|
||||
|
|
|
|||
Loading…
Reference in a new issue