Fix browse search query display and keyboard focus (#8781)
This commit is contained in:
parent
8e1b5b4803
commit
a8230ad574
2 changed files with 19 additions and 16 deletions
|
@ -319,6 +319,7 @@ fun SearchToolbar(
|
||||||
)
|
)
|
||||||
LaunchedEffect(searchClickCount) {
|
LaunchedEffect(searchClickCount) {
|
||||||
if (searchQuery == null) return@LaunchedEffect
|
if (searchQuery == null) return@LaunchedEffect
|
||||||
|
if (searchClickCount == 0 && searchQuery.isNotEmpty()) return@LaunchedEffect
|
||||||
try {
|
try {
|
||||||
focusRequester.requestFocus()
|
focusRequester.requestFocus()
|
||||||
} catch (_: Throwable) {
|
} catch (_: Throwable) {
|
||||||
|
|
|
@ -103,6 +103,24 @@ class BrowseSourceScreenModel(
|
||||||
|
|
||||||
val source = sourceManager.get(sourceId) as CatalogueSource
|
val source = sourceManager.get(sourceId) as CatalogueSource
|
||||||
|
|
||||||
|
init {
|
||||||
|
mutableState.update {
|
||||||
|
var query: String? = null
|
||||||
|
var listing = it.listing
|
||||||
|
|
||||||
|
if (listing is Listing.Search) {
|
||||||
|
query = listing.query
|
||||||
|
listing = Listing.Search(query, source.getFilterList())
|
||||||
|
}
|
||||||
|
|
||||||
|
it.copy(
|
||||||
|
listing = listing,
|
||||||
|
filters = source.getFilterList(),
|
||||||
|
toolbarQuery = query,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sheet containing filter items.
|
* Sheet containing filter items.
|
||||||
*/
|
*/
|
||||||
|
@ -132,22 +150,6 @@ class BrowseSourceScreenModel(
|
||||||
}
|
}
|
||||||
.stateIn(coroutineScope, SharingStarted.Lazily, emptyFlow())
|
.stateIn(coroutineScope, SharingStarted.Lazily, emptyFlow())
|
||||||
|
|
||||||
init {
|
|
||||||
mutableState.update {
|
|
||||||
val initialListing = it.listing
|
|
||||||
val listing = if (initialListing is Listing.Search) {
|
|
||||||
initialListing.copy(filters = source.getFilterList())
|
|
||||||
} else {
|
|
||||||
initialListing
|
|
||||||
}
|
|
||||||
|
|
||||||
it.copy(
|
|
||||||
listing = listing,
|
|
||||||
filters = source.getFilterList(),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun getColumnsPreference(orientation: Int): GridCells {
|
fun getColumnsPreference(orientation: Int): GridCells {
|
||||||
val isLandscape = orientation == Configuration.ORIENTATION_LANDSCAPE
|
val isLandscape = orientation == Configuration.ORIENTATION_LANDSCAPE
|
||||||
val columns = if (isLandscape) {
|
val columns = if (isLandscape) {
|
||||||
|
|
Reference in a new issue