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