diff --git a/app/src/main/java/eu/kanade/domain/DomainModule.kt b/app/src/main/java/eu/kanade/domain/DomainModule.kt index 0c2777dbd..3fc504d98 100644 --- a/app/src/main/java/eu/kanade/domain/DomainModule.kt +++ b/app/src/main/java/eu/kanade/domain/DomainModule.kt @@ -79,7 +79,7 @@ class DomainModule : InjektModule { addFactory { ResetCategoryFlags(get(), get()) } addFactory { SetDisplayModeForCategory(get(), get()) } addFactory { SetSortModeForCategory(get(), get()) } - addFactory { CreateCategoryWithName(get()) } + addFactory { CreateCategoryWithName(get(), get()) } addFactory { RenameCategory(get()) } addFactory { ReorderCategory(get()) } addFactory { UpdateCategory(get()) } diff --git a/app/src/main/java/eu/kanade/domain/category/interactor/CreateCategoryWithName.kt b/app/src/main/java/eu/kanade/domain/category/interactor/CreateCategoryWithName.kt index b4c035bc4..efd615a7d 100644 --- a/app/src/main/java/eu/kanade/domain/category/interactor/CreateCategoryWithName.kt +++ b/app/src/main/java/eu/kanade/domain/category/interactor/CreateCategoryWithName.kt @@ -3,6 +3,7 @@ package eu.kanade.domain.category.interactor import eu.kanade.domain.category.model.Category import eu.kanade.domain.category.model.anyWithName import eu.kanade.domain.category.repository.CategoryRepository +import eu.kanade.tachiyomi.data.preference.PreferencesHelper import eu.kanade.tachiyomi.util.system.logcat import kotlinx.coroutines.NonCancellable import kotlinx.coroutines.withContext @@ -10,8 +11,16 @@ import logcat.LogPriority class CreateCategoryWithName( private val categoryRepository: CategoryRepository, + private val preferences: PreferencesHelper, ) { + private val initialFlags: Long + get() { + return preferences.libraryDisplayMode().get().flag or + preferences.librarySortingMode().get().flag or + preferences.librarySortingAscending().get().flag + } + suspend fun await(name: String): Result = withContext(NonCancellable) { val categories = categoryRepository.getAll() if (categories.anyWithName(name)) { @@ -23,7 +32,7 @@ class CreateCategoryWithName( id = 0, name = name, order = nextOrder, - flags = 0, + flags = initialFlags, ) try {