mirror of
https://github.com/DaanVandenBosch/phantasmal-world.git
synced 2025-04-04 22:58:29 +08:00
Fixed sorting bug in hunt optimizer methods tables. Tables were sorted incorrectly after changing method times.
This commit is contained in:
parent
12883de487
commit
dceb80afec
@ -57,14 +57,10 @@ class MethodsForEpisodeController(
|
|||||||
}.toTypedArray()
|
}.toTypedArray()
|
||||||
)
|
)
|
||||||
|
|
||||||
init {
|
private var sortColumns: List<SortColumn<HuntMethodModel>> = emptyList()
|
||||||
observe(huntMethodStore.methods) { allMethods ->
|
|
||||||
methods.value = allMethods.filter { it.episode == episode }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun sort(sortColumns: List<SortColumn<HuntMethodModel>>) {
|
private val comparator: Comparator<HuntMethodModel> =
|
||||||
methods.sortWith { a, b ->
|
Comparator { a, b ->
|
||||||
for (sortColumn in sortColumns) {
|
for (sortColumn in sortColumns) {
|
||||||
val cmp = when (sortColumn.column.key) {
|
val cmp = when (sortColumn.column.key) {
|
||||||
METHOD_COL_KEY ->
|
METHOD_COL_KEY ->
|
||||||
@ -79,12 +75,27 @@ class MethodsForEpisodeController(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (cmp != 0) {
|
if (cmp != 0) {
|
||||||
return@sortWith if (sortColumn.direction == SortDirection.Asc) cmp else -cmp
|
return@Comparator if (sortColumn.direction == SortDirection.Asc) cmp else -cmp
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
0
|
0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
init {
|
||||||
|
// TODO: Use ListCell.sortedWith when this is available.
|
||||||
|
observe(huntMethodStore.methods) { allMethods ->
|
||||||
|
methods.value = allMethods
|
||||||
|
.asSequence()
|
||||||
|
.filter { it.episode == episode }
|
||||||
|
.sortedWith(comparator)
|
||||||
|
.toList()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun sort(sortColumns: List<SortColumn<HuntMethodModel>>) {
|
||||||
|
this.sortColumns = sortColumns
|
||||||
|
methods.sortWith(comparator)
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun setMethodTime(method: HuntMethodModel, time: Duration) {
|
suspend fun setMethodTime(method: HuntMethodModel, time: Duration) {
|
||||||
|
Loading…
Reference in New Issue
Block a user