From 633bd6eb462ee187fb3c1d6c3f8f025cb0f9eedc Mon Sep 17 00:00:00 2001 From: Ivan Iskandar <12537387+ivaniskandar@users.noreply.github.com> Date: Wed, 28 Sep 2022 04:44:41 +0700 Subject: [PATCH] UpdatesScreen: Fix selection state after deleting download (#8100) --- .../main/java/eu/kanade/presentation/updates/UpdatesScreen.kt | 2 +- .../main/java/eu/kanade/tachiyomi/ui/manga/MangaController.kt | 1 + .../main/java/eu/kanade/tachiyomi/ui/manga/MangaPresenter.kt | 2 +- .../eu/kanade/tachiyomi/ui/recent/updates/UpdatesPresenter.kt | 2 +- 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/eu/kanade/presentation/updates/UpdatesScreen.kt b/app/src/main/java/eu/kanade/presentation/updates/UpdatesScreen.kt index 67f72b85d..addf406ac 100644 --- a/app/src/main/java/eu/kanade/presentation/updates/UpdatesScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/updates/UpdatesScreen.kt @@ -196,8 +196,8 @@ private fun UpdateScreenContent( UpdatesDeleteConfirmationDialog( onDismissRequest = onDismissDialog, onConfirm = { - presenter.deleteChapters(dialog.toDelete) presenter.toggleAllSelection(false) + presenter.deleteChapters(dialog.toDelete) }, ) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaController.kt index 696d4e082..b19bf884e 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaController.kt @@ -161,6 +161,7 @@ class MangaController : FullComposeController { DeleteChaptersDialog( onDismissRequest = onDismissRequest, onConfirm = { + presenter.toggleAllSelection(false) deleteChapters(dialog.chapters) }, ) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaPresenter.kt index c25611509..91c48d959 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaPresenter.kt @@ -646,6 +646,7 @@ class MangaPresenter( /** * Deletes the given list of chapter. + * * @param chapters the list of chapters to delete. */ fun deleteChapters(chapters: List) { @@ -673,7 +674,6 @@ class MangaPresenter( } successState.copy(chapters = newChapters) } - toggleAllSelection(false) } catch (e: Throwable) { logcat(LogPriority.ERROR, e) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/recent/updates/UpdatesPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/recent/updates/UpdatesPresenter.kt index 3712f9921..ccbd5dfe4 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/recent/updates/UpdatesPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/recent/updates/UpdatesPresenter.kt @@ -274,7 +274,7 @@ class UpdatesPresenter( if (deletedUpdates.isEmpty()) return@launchNonCancellable // TODO: Don't do this fake status update - state.items = items.toMutableList().apply { + state.items = state.items.toMutableList().apply { deletedUpdates.forEach { deletedUpdate -> val modifiedIndex = indexOf(deletedUpdate) val item = removeAt(modifiedIndex).copy(