diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaDetailsController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaDetailsController.kt index 714295d87e..b1e7959f67 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaDetailsController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaDetailsController.kt @@ -1088,7 +1088,7 @@ class MangaDetailsController : BaseController, presenter.toggleFavorite() showAddedSnack() } - val ids = presenter.getMangaCategoryIds(manga) + val ids = presenter.getMangaCategoryIds() val preselected = ids.mapNotNull { id -> categories.indexOfFirst { it.id == id }.takeIf { it != -1 } }.toTypedArray() @@ -1115,24 +1115,23 @@ class MangaDetailsController : BaseController, } private fun toggleMangaFavorite() { - val manga = presenter.manga if (presenter.toggleFavorite()) { val categories = presenter.getCategories() val defaultCategoryId = presenter.preferences.defaultCategory() val defaultCategory = categories.find { it.id == defaultCategoryId } when { - defaultCategory != null -> presenter.moveMangaToCategory(manga, defaultCategory) + defaultCategory != null -> presenter.moveMangaToCategory(defaultCategory) defaultCategoryId == 0 || categories.isEmpty() -> // 'Default' or no category - presenter.moveMangaToCategory(manga, null) + presenter.moveMangaToCategory(null) else -> { - val ids = presenter.getMangaCategoryIds(manga) + val ids = presenter.getMangaCategoryIds() val preselected = ids.mapNotNull { id -> categories.indexOfFirst { it.id == id }.takeIf { it != -1 } }.toTypedArray() AddToLibraryCategoriesDialog( this, - manga, + presenter.manga, categories, preselected ).showDialog(router) @@ -1174,12 +1173,11 @@ class MangaDetailsController : BaseController, override fun mangaPresenter(): MangaDetailsPresenter = presenter override fun updateCategoriesForMangas(mangas: List, categories: List) { - val manga = mangas.firstOrNull() ?: return - presenter.moveMangaToCategories(manga, categories) + presenter.moveMangaToCategories(categories) } override fun updateCategoriesForManga(manga: Manga?, categories: List) { - manga?.let { presenter.moveMangaToCategories(manga, categories) } + manga?.let { presenter.moveMangaToCategories(categories) } } override fun addToLibraryCancelled(manga: Manga?, position: Int) { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaDetailsPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaDetailsPresenter.kt index dedb3f7f07..63b3696ede 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaDetailsPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaDetailsPresenter.kt @@ -375,6 +375,7 @@ class MangaDetailsPresenter( if (update) controller.updateChapters(this.chapters) } + /** Refresh Manga Info and Chapter List (not tracking) */ fun refreshAll() { scope.launch { isLoading = true @@ -590,8 +591,8 @@ class MangaDetailsPresenter( * @param manga the manga to move. * @param category the selected category, or null for default category. */ - fun moveMangaToCategory(manga: Manga, category: Category?) { - moveMangaToCategories(manga, listOfNotNull(category)) + fun moveMangaToCategory(category: Category?) { + moveMangaToCategories(listOfNotNull(category)) } /** @@ -600,7 +601,7 @@ class MangaDetailsPresenter( * @param manga the manga to move. * @param categories the selected categories. */ - fun moveMangaToCategories(manga: Manga, categories: List) { + fun moveMangaToCategories(categories: List) { val mc = categories.filter { it.id != 0 }.map { MangaCategory.create(manga, it) } db.setMangaCategories(mc, listOf(manga)) } @@ -611,7 +612,7 @@ class MangaDetailsPresenter( * @param manga the manga to get categories from. * @return Array of category ids the manga is in, if none returns default id */ - fun getMangaCategoryIds(manga: Manga): Array { + fun getMangaCategoryIds(): Array { val categories = db.getCategoriesForManga(manga).executeAsBlocking() return categories.mapNotNull { it.id }.toTypedArray() }