mirror of
https://github.com/mihonapp/mihon.git
synced 2025-10-20 18:19:43 +02:00
Keyed random seed
This commit is contained in:
@@ -6,6 +6,7 @@ import tachiyomi.domain.category.repository.CategoryRepository
|
||||
import tachiyomi.domain.library.model.LibrarySort
|
||||
import tachiyomi.domain.library.model.plus
|
||||
import tachiyomi.domain.library.service.LibraryPreferences
|
||||
import kotlin.random.Random
|
||||
|
||||
class SetSortModeForCategory(
|
||||
private val preferences: LibraryPreferences,
|
||||
@@ -15,6 +16,9 @@ class SetSortModeForCategory(
|
||||
suspend fun await(categoryId: Long?, type: LibrarySort.Type, direction: LibrarySort.Direction) {
|
||||
val category = categoryId?.let { categoryRepository.get(it) }
|
||||
val flags = (category?.flags ?: 0) + type + direction
|
||||
if (type == LibrarySort.Type.Random) {
|
||||
preferences.currentRandomSortSeed().set(Random.nextInt())
|
||||
}
|
||||
if (category != null && preferences.categorizedDisplaySettings().get()) {
|
||||
categoryRepository.updatePartial(
|
||||
CategoryUpdate(
|
||||
|
||||
@@ -26,6 +26,8 @@ class LibraryPreferences(
|
||||
LibrarySort.Serializer::deserialize,
|
||||
)
|
||||
|
||||
fun currentRandomSortSeed() = preferenceStore.getInt("library_random_sort_seed", 0)
|
||||
|
||||
fun portraitColumns() = preferenceStore.getInt("pref_library_columns_portrait_key", 0)
|
||||
|
||||
fun landscapeColumns() = preferenceStore.getInt("pref_library_columns_landscape_key", 0)
|
||||
|
||||
Reference in New Issue
Block a user