Wait until search actions are ready before presenting any results
This commit is contained in:
parent
b1077fad12
commit
838a696b17
@ -86,6 +86,7 @@ internal class SearchServiceImpl(
|
||||
websites: WebsiteSearchSettings,
|
||||
wikipedia: WikipediaSearchSettings,
|
||||
): Flow<ImmutableList<Searchable>> = channelFlow {
|
||||
var searchActionsReady = false
|
||||
supervisorScope {
|
||||
val results = MutableStateFlow(SearchResults())
|
||||
launch {
|
||||
@ -220,6 +221,7 @@ internal class SearchServiceImpl(
|
||||
searchActionService.search(query)
|
||||
.collectLatest { r ->
|
||||
results.update {
|
||||
searchActionsReady = true
|
||||
it.copy(searchActions = r)
|
||||
}
|
||||
}
|
||||
@ -228,7 +230,7 @@ internal class SearchServiceImpl(
|
||||
results
|
||||
.map { it.toList().sortedBy { it as? SavableSearchable }.toImmutableList() }
|
||||
.collectLatest {
|
||||
send(it)
|
||||
if (searchActionsReady) send(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -8,6 +8,7 @@ import androidx.compose.animation.core.updateTransition
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.ColumnScope
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.RowScope
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
@ -52,7 +53,7 @@ fun SearchBar(
|
||||
reverse: Boolean = false,
|
||||
darkColors: Boolean = false,
|
||||
menu: @Composable RowScope.() -> Unit = {},
|
||||
actions: @Composable () -> Unit = {},
|
||||
actions: @Composable ColumnScope.() -> Unit = {},
|
||||
) {
|
||||
|
||||
val transition = updateTransition(level, label = "Searchbar")
|
||||
@ -179,7 +180,7 @@ fun SearchBar(
|
||||
menu()
|
||||
}
|
||||
}
|
||||
actions()
|
||||
this.actions()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,6 +2,7 @@ package de.mm20.launcher2.ui.launcher.searchbar
|
||||
|
||||
import android.content.Intent
|
||||
import androidx.compose.animation.AnimatedVisibility
|
||||
import androidx.compose.foundation.layout.ColumnScope
|
||||
import androidx.compose.foundation.layout.PaddingValues
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.padding
|
||||
@ -24,7 +25,7 @@ import de.mm20.launcher2.ui.component.SearchActionIcon
|
||||
import de.mm20.launcher2.ui.settings.SettingsActivity
|
||||
|
||||
@Composable
|
||||
fun SearchBarActions(
|
||||
fun ColumnScope.SearchBarActions(
|
||||
modifier: Modifier = Modifier,
|
||||
actions: List<SearchAction>,
|
||||
reverse: Boolean = false,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user