From 7f50f0ca146e1215553453840fffc639212299c9 Mon Sep 17 00:00:00 2001 From: Luna712 <142361265+Luna712@users.noreply.github.com> Date: Tue, 9 Jul 2024 16:32:22 -0600 Subject: [PATCH] Support deleting all episodes in a series --- .../cloudstream3/ui/download/DownloadViewModel.kt | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/download/DownloadViewModel.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/download/DownloadViewModel.kt index a812bddd..c738ff70 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/download/DownloadViewModel.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/download/DownloadViewModel.kt @@ -241,7 +241,20 @@ class DownloadViewModel : ViewModel() { fun handleMultiDelete(context: Context) = viewModelScope.launchSafe { val selectedItemsList = selectedItems.value ?: mutableListOf() - val ids = selectedItemsList.map { it.data.id } + val ids = selectedItemsList.flatMap { item -> + when (item) { + is VisualDownloadCached.Header -> { + if (item.data.type.isEpisodeBased()) { + context.getKeys(DOWNLOAD_EPISODE_CACHE) + .mapNotNull { context.getKey(it) } + .filter { it.parentId == item.data.id } + .map { it.id } + } else listOf(item.data.id) + } + + is VisualDownloadCached.Child -> listOf(item.data.id) + } + } val (seriesNames, names) = selectedItemsList.map { item -> when (item) {