From 8ebda219c4b45a24c83e7c40c8ab218ec2fd07f2 Mon Sep 17 00:00:00 2001 From: Harsh Parekh Date: Sun, 26 May 2019 05:37:47 -0400 Subject: [PATCH] Fix the category selection bug (#2052) Fixes #2051 --- .../ui/manga/info/MangaInfoController.kt | 23 ++++++++----------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/info/MangaInfoController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/info/MangaInfoController.kt index 0a3a409733..5340627072 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/info/MangaInfoController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/info/MangaInfoController.kt @@ -413,20 +413,17 @@ class MangaInfoController : NucleusController(), activity?.toast(activity?.getString(R.string.manga_added_library)) } val categories = presenter.getCategories() - val defaultCategory = categories.find { it.id == preferences.defaultCategory() } - when { - defaultCategory != null -> presenter.moveMangaToCategory(manga, defaultCategory) - categories.size <= 1 -> // default or the one from the user - presenter.moveMangaToCategory(manga, categories.firstOrNull()) - else -> { - val ids = presenter.getMangaCategoryIds(manga) - val preselected = ids.mapNotNull { id -> - categories.indexOfFirst { it.id == id }.takeIf { it != -1 } - }.toTypedArray() + if (categories.size <= 1) { + // default or the one from the user then just add to favorite. + presenter.moveMangaToCategory(manga, categories.firstOrNull()) + } else { + val ids = presenter.getMangaCategoryIds(manga) + val preselected = ids.mapNotNull { id -> + categories.indexOfFirst { it.id == id }.takeIf { it != -1 } + }.toTypedArray() - ChangeMangaCategoriesDialog(this, listOf(manga), categories, preselected) - .showDialog(router) - } + ChangeMangaCategoriesDialog(this, listOf(manga), categories, preselected) + .showDialog(router) } }