Skip to content

Commit

Permalink
Sort battle configs by server, then name (#1741)
Browse files Browse the repository at this point in the history
  • Loading branch information
ArthurKun21 authored Jan 4, 2024
1 parent e8475a0 commit a9bcf3d
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import androidx.lifecycle.viewModelScope
import com.google.gson.Gson
import dagger.hilt.android.lifecycle.HiltViewModel
import io.github.fate_grand_automata.R
import io.github.fate_grand_automata.prefs.core.BattleConfigCore
import io.github.fate_grand_automata.prefs.core.PrefsCore
import io.github.fate_grand_automata.scripts.prefs.IBattleConfig
import io.github.fate_grand_automata.scripts.prefs.IPreferences
Expand All @@ -34,7 +35,15 @@ class BattleConfigListViewModel @Inject constructor(
.map { list ->
list
.map { key -> prefsCore.forBattleConfig(key) }
.sortedWith(compareBy(String.CASE_INSENSITIVE_ORDER) { it.name.get() })
.sortedWith(
compareByDescending<BattleConfigCore> {
it.server.get() == BattleConfigCore.Server.NotSet
}.thenByDescending {
it.server.get().asGameServer().toString()
}.thenBy(String.CASE_INSENSITIVE_ORDER) {
it.name.get()
}
)
}

private val _selectedConfigs = MutableStateFlow(emptySet<String>())
Expand Down

0 comments on commit a9bcf3d

Please sign in to comment.