mirror of
https://github.com/mihonapp/mihon.git
synced 2024-11-10 04:37:25 +01:00
Set initial flag on new categories (#7800)
- Use the same flag as other categories - Per-category uses the flag the user used before starting to use per-category
This commit is contained in:
parent
09abfc7843
commit
4228bbb88e
@ -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()) }
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user