Check last entry

Signed-off-by: alperozturk <alper_ozturk@proton.me>
This commit is contained in:
alperozturk 2024-06-26 14:36:01 +02:00
parent 59e721c405
commit a971dbd5d2
No known key found for this signature in database
GPG key ID: 4E577DC593B59BDF

View file

@ -43,7 +43,6 @@ class UnifiedSearchViewModel(application: Application) : AndroidViewModel(applic
null null
} }
} }
fun name(): String? = results.lastOrNull()?.name fun name(): String? = results.lastOrNull()?.name
} }
@ -197,11 +196,13 @@ class UnifiedSearchViewModel(application: Application) : AndroidViewModel(applic
searchResults.value = results searchResults.value = results
.filter { it.value.results.isNotEmpty() } .filter { it.value.results.isNotEmpty() }
.map { (key, value) -> .map { (key, value) ->
val isLastEntryHaveValue = results[key]?.results?.last()?.entries?.isEmpty() != true
UnifiedSearchSection( UnifiedSearchSection(
providerID = key, providerID = key,
name = value.name()!!, name = value.name()!!,
entries = value.results.flatMap { it.entries }, entries = value.results.flatMap { it.entries },
hasMoreResults = results.isNotEmpty() && results[key]?.nextCursor() != null hasMoreResults = isLastEntryHaveValue && results[key]?.nextCursor() != null
) )
} }
.sortedWith { o1, o2 -> .sortedWith { o1, o2 ->