From 0f228a6967b17ada4a832a73f6c5cb092526b8d8 Mon Sep 17 00:00:00 2001 From: Jay Date: Thu, 6 Feb 2020 12:53:12 -0800 Subject: [PATCH] Fixed default category not saying D&D mode after disabling categories --- .../tachiyomi/ui/library/LibraryPresenter.kt | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryPresenter.kt index 30274c3062..2b0fa3b32f 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryPresenter.kt @@ -204,11 +204,8 @@ class LibraryPresenter( db.getTotalChapterManga().executeAsBlocking().associate { it.id!! to counter++ } } val catListing by lazy { - val default = Category.createDefault(context) + val default = createDefaultCategory() default.order = -1 - val defOrder = preferences.defaultMangaOrder().getOrDefault() - if (defOrder.firstOrNull()?.isLetter() == true) default.mangaSort = defOrder.first() - else default.mangaOrder = defOrder.split("/").mapNotNull { it.toLongOrNull() } listOf(default) + db.getCategories().executeAsBlocking() } @@ -300,17 +297,25 @@ class LibraryPresenter( private fun getLibraryObservable(): Observable { return Observable.combineLatest(getCategoriesObservable(), getLibraryMangasObservable()) { dbCategories, libraryManga -> val categories = if (libraryManga.containsKey(0)) - arrayListOf(Category.createDefault(context)) + dbCategories + arrayListOf(createDefaultCategory()) + dbCategories else dbCategories this.allCategories = categories this.categories = if (!preferences.showCategories().getOrDefault()) - arrayListOf(Category.createDefault(context)) + arrayListOf(createDefaultCategory()) else categories Library(this.categories, libraryManga) } } + private fun createDefaultCategory(): Category { + val default = Category.createDefault(context) + val defOrder = preferences.defaultMangaOrder().getOrDefault() + if (defOrder.firstOrNull()?.isLetter() == true) default.mangaSort = defOrder.first() + else default.mangaOrder = defOrder.split("/").mapNotNull { it.toLongOrNull() } + return default + } + /** * Get the categories from the database. *