mirror of
https://github.com/mihonapp/mihon.git
synced 2025-06-29 04:27:51 +02:00
Fix crash when trying use source sort filter without a pre-selection (#2036)
This commit is contained in:
@ -128,22 +128,24 @@ private fun FilterItem(filter: Filter<*>, onUpdate: () -> Unit) {
|
||||
) {
|
||||
Column {
|
||||
filter.values.mapIndexed { index, item ->
|
||||
val sortAscending = filter.state?.ascending
|
||||
?.takeIf { index == filter.state?.index }
|
||||
SortItem(
|
||||
label = item,
|
||||
sortDescending = filter.state?.ascending?.not()
|
||||
?.takeIf { index == filter.state?.index },
|
||||
) {
|
||||
val ascending = if (index == filter.state?.index) {
|
||||
!filter.state!!.ascending
|
||||
} else {
|
||||
filter.state!!.ascending
|
||||
}
|
||||
filter.state = Filter.Sort.Selection(
|
||||
index = index,
|
||||
ascending = ascending,
|
||||
)
|
||||
onUpdate()
|
||||
}
|
||||
sortDescending = if (sortAscending != null) !sortAscending else null,
|
||||
onClick = {
|
||||
val ascending = if (index == filter.state?.index) {
|
||||
!filter.state!!.ascending
|
||||
} else {
|
||||
filter.state?.ascending ?: true
|
||||
}
|
||||
filter.state = Filter.Sort.Selection(
|
||||
index = index,
|
||||
ascending = ascending,
|
||||
)
|
||||
onUpdate()
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user