mirror of
https://github.com/recloudstream/cloudstream.git
synced 2024-08-15 01:53:11 +00:00
Fix updating child list on deletion
This commit is contained in:
parent
20b2fcaedc
commit
80281e9773
3 changed files with 22 additions and 6 deletions
|
@ -163,7 +163,12 @@ class DownloadChildFragment : Fragment() {
|
|||
attachBackPressedCallback()
|
||||
|
||||
binding?.btnDelete?.setOnClickListener {
|
||||
context?.let { ctx -> downloadsViewModel.handleMultiDelete(ctx) }
|
||||
context?.let { ctx ->
|
||||
downloadsViewModel.handleMultiDelete(ctx) {
|
||||
arguments?.getString("folder")
|
||||
?.let { folder -> downloadsViewModel.updateChildList(ctx, folder) }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
binding?.btnCancel?.setOnClickListener {
|
||||
|
|
|
@ -224,7 +224,11 @@ class DownloadFragment : Fragment() {
|
|||
attachBackPressedCallback()
|
||||
|
||||
binding?.btnDelete?.setOnClickListener {
|
||||
context?.let { ctx -> downloadsViewModel.handleMultiDelete(ctx) }
|
||||
context?.let { ctx ->
|
||||
downloadsViewModel.handleMultiDelete(ctx) {
|
||||
downloadsViewModel.updateList(ctx)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
binding?.btnCancel?.setOnClickListener {
|
||||
|
|
|
@ -239,7 +239,7 @@ class DownloadViewModel : ViewModel() {
|
|||
}
|
||||
}
|
||||
|
||||
fun handleMultiDelete(context: Context) = viewModelScope.launchSafe {
|
||||
fun handleMultiDelete(context: Context, onDeleteConfirm: () -> Unit) = viewModelScope.launchSafe {
|
||||
val selectedItemsList = selectedItems.value ?: mutableListOf()
|
||||
|
||||
val ids = selectedItemsList.flatMap { item ->
|
||||
|
@ -279,14 +279,21 @@ class DownloadViewModel : ViewModel() {
|
|||
}
|
||||
}.unzip()
|
||||
|
||||
showDeleteConfirmationDialog(context, ids, names.filterNotNull(), seriesNames.filterNotNull())
|
||||
showDeleteConfirmationDialog(
|
||||
context,
|
||||
ids,
|
||||
names.filterNotNull(),
|
||||
seriesNames.filterNotNull(),
|
||||
onDeleteConfirm
|
||||
)
|
||||
}
|
||||
|
||||
private fun showDeleteConfirmationDialog(
|
||||
context: Context,
|
||||
ids: List<Int>,
|
||||
names: List<String>,
|
||||
seriesNames: List<String>
|
||||
seriesNames: List<String>,
|
||||
onDeleteConfirm: () -> Unit
|
||||
) {
|
||||
val formattedNames = names.joinToString(separator = "\n") { "• $it" }
|
||||
val formattedSeriesNames = seriesNames.joinToString(separator = "\n") { "• $it" }
|
||||
|
@ -310,7 +317,7 @@ class DownloadViewModel : ViewModel() {
|
|||
viewModelScope.launchSafe {
|
||||
deleteFilesAndUpdateSettings(context, ids, this)
|
||||
setIsMultiDeleteState(false)
|
||||
updateList(context)
|
||||
onDeleteConfirm.invoke()
|
||||
}
|
||||
}
|
||||
DialogInterface.BUTTON_NEGATIVE -> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue