diff --git a/data/src/main/java/tachiyomi/data/category/CategoryRepositoryImpl.kt b/data/src/main/java/tachiyomi/data/category/CategoryRepositoryImpl.kt index 729703d54..c60fd9daa 100644 --- a/data/src/main/java/tachiyomi/data/category/CategoryRepositoryImpl.kt +++ b/data/src/main/java/tachiyomi/data/category/CategoryRepositoryImpl.kt @@ -77,6 +77,9 @@ class CategoryRepositoryImpl( override suspend fun updateAllOrders(orderedIds: List) { database.transaction { + orderedIds.forEachIndexed { index, categoryId -> + database.categoriesQueries.updateOrder(order = -index - 2L, categoryId = categoryId) + } orderedIds.forEachIndexed { index, categoryId -> database.categoriesQueries.updateOrder(order = index.toLong(), categoryId = categoryId) } diff --git a/domain/src/main/java/tachiyomi/domain/category/interactor/DeleteCategory.kt b/domain/src/main/java/tachiyomi/domain/category/interactor/DeleteCategory.kt index bbdbe3b7d..71050a5d6 100644 --- a/domain/src/main/java/tachiyomi/domain/category/interactor/DeleteCategory.kt +++ b/domain/src/main/java/tachiyomi/domain/category/interactor/DeleteCategory.kt @@ -4,6 +4,7 @@ import dev.zacsweers.metro.Inject import logcat.LogPriority import tachiyomi.core.common.util.lang.withNonCancellableContext import tachiyomi.core.common.util.system.logcat +import tachiyomi.domain.category.model.Category import tachiyomi.domain.category.repository.CategoryRepository import tachiyomi.domain.download.service.DownloadPreferences import tachiyomi.domain.library.service.LibraryPreferences @@ -23,7 +24,9 @@ class DeleteCategory( return@withNonCancellableContext Result.InternalError(e) } - val orderedIds = categoryRepository.getAll().map { it.id } + val orderedIds = categoryRepository.getAll() + .filterNot(Category::isSystemCategory) + .map { it.id } val defaultCategory = libraryPreferences.defaultCategory.get() if (defaultCategory == categoryId.toInt()) {