mirror of
https://github.com/mihonapp/mihon.git
synced 2025-02-12 10:08:55 +01:00
Compare commits
6 Commits
ab0893b2d4
...
dae7a00b41
Author | SHA1 | Date | |
---|---|---|---|
|
dae7a00b41 | ||
|
c3adf103d7 | ||
|
945ae821fb | ||
|
aefce87650 | ||
|
c70685584f | ||
|
36c864d873 |
@ -184,14 +184,10 @@ private fun ColumnScope.SortPage(
|
||||
MR.strings.action_sort_random to LibrarySort.Type.Random,
|
||||
).plus(trackerSortOption).map { (titleRes, mode) ->
|
||||
if (mode == LibrarySort.Type.Random) {
|
||||
val enabledIcon = if (sortingMode == LibrarySort.Type.Random) {
|
||||
Icons.Default.Refresh
|
||||
} else {
|
||||
null
|
||||
}
|
||||
BaseSortItem(
|
||||
label = stringResource(titleRes),
|
||||
icon = enabledIcon,
|
||||
icon = Icons.Default.Refresh
|
||||
.takeIf { sortingMode == LibrarySort.Type.Random },
|
||||
onClick = {
|
||||
screenModel.setSort(category, mode, LibrarySort.Direction.Ascending)
|
||||
},
|
||||
|
@ -302,16 +302,15 @@ class LibraryScreenModel(
|
||||
item1Score.compareTo(item2Score)
|
||||
}
|
||||
LibrarySort.Type.Random -> {
|
||||
error("A comparator should not be requested for the random sort style. Instead, intercept this " +
|
||||
"case and call .shuffle()")
|
||||
error("Why Are We Still Here? Just To Suffer?")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return mapValues { (key, value) ->
|
||||
if (key.sort.type == LibrarySort.Type.Random) {
|
||||
return@mapValues value.shuffled(Random(libraryPreferences.currentRandomSortSeed().get()))
|
||||
}
|
||||
if (key.sort.type == LibrarySort.Type.Random) {
|
||||
return@mapValues value.shuffled(Random(libraryPreferences.randomSortSeed().get()))
|
||||
}
|
||||
|
||||
val comparator = key.sort.comparator()
|
||||
.let { if (key.sort.isAscending) it else it.reversed() }
|
||||
|
@ -17,7 +17,7 @@ class SetSortModeForCategory(
|
||||
val category = categoryId?.let { categoryRepository.get(it) }
|
||||
val flags = (category?.flags ?: 0) + type + direction
|
||||
if (type == LibrarySort.Type.Random) {
|
||||
preferences.currentRandomSortSeed().set(Random.nextInt())
|
||||
preferences.randomSortSeed().set(Random.nextInt())
|
||||
}
|
||||
if (category != null && preferences.categorizedDisplaySettings().get()) {
|
||||
categoryRepository.updatePartial(
|
||||
|
@ -31,7 +31,7 @@ data class LibrarySort(
|
||||
data object ChapterFetchDate : Type(0b00011000)
|
||||
data object DateAdded : Type(0b00011100)
|
||||
data object TrackerMean : Type(0b00100000)
|
||||
data object Random : Type(0b00100100)
|
||||
data object Random : Type(0b00111100)
|
||||
|
||||
companion object {
|
||||
fun valueOf(flag: Long): Type {
|
||||
|
@ -26,7 +26,7 @@ class LibraryPreferences(
|
||||
LibrarySort.Serializer::deserialize,
|
||||
)
|
||||
|
||||
fun currentRandomSortSeed() = preferenceStore.getInt("library_random_sort_seed", 0)
|
||||
fun randomSortSeed() = preferenceStore.getInt("library_random_sort_seed", 0)
|
||||
|
||||
fun portraitColumns() = preferenceStore.getInt("pref_library_columns_portrait_key", 0)
|
||||
|
||||
|
@ -17,7 +17,6 @@ import androidx.compose.foundation.lazy.grid.LazyVerticalGrid
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.ArrowDownward
|
||||
import androidx.compose.material.icons.filled.ArrowUpward
|
||||
import androidx.compose.material.icons.filled.Refresh
|
||||
import androidx.compose.material.icons.rounded.CheckBox
|
||||
import androidx.compose.material.icons.rounded.CheckBoxOutlineBlank
|
||||
import androidx.compose.material.icons.rounded.DisabledByDefault
|
||||
|
Loading…
x
Reference in New Issue
Block a user