mirror of
https://github.com/mihonapp/mihon.git
synced 2025-10-17 08:39:43 +02:00
Remove alphabetical category sort option (#1781)
This commit is contained in:
@@ -12,10 +12,9 @@ import tachiyomi.domain.category.repository.CategoryRepository
|
||||
class ReorderCategory(
|
||||
private val categoryRepository: CategoryRepository,
|
||||
) {
|
||||
|
||||
private val mutex = Mutex()
|
||||
|
||||
suspend fun changeOrder(category: Category, newIndex: Int) = withNonCancellableContext {
|
||||
suspend fun await(category: Category, newIndex: Int) = withNonCancellableContext {
|
||||
mutex.withLock {
|
||||
val categories = categoryRepository.getAll()
|
||||
.filterNot(Category::isSystemCategory)
|
||||
@@ -45,27 +44,6 @@ class ReorderCategory(
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun sortAlphabetically() = withNonCancellableContext {
|
||||
mutex.withLock {
|
||||
val updates = categoryRepository.getAll()
|
||||
.sortedBy { category -> category.name }
|
||||
.mapIndexed { index, category ->
|
||||
CategoryUpdate(
|
||||
id = category.id,
|
||||
order = index.toLong(),
|
||||
)
|
||||
}
|
||||
|
||||
try {
|
||||
categoryRepository.updatePartial(updates)
|
||||
Result.Success
|
||||
} catch (e: Exception) {
|
||||
logcat(LogPriority.ERROR, e)
|
||||
Result.InternalError(e)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sealed interface Result {
|
||||
data object Success : Result
|
||||
data object Unchanged : Result
|
||||
|
Reference in New Issue
Block a user