From ad2539c28d3be9539771b586aecddd975177caf6 Mon Sep 17 00:00:00 2001 From: Bnyro Date: Mon, 31 Mar 2025 16:47:38 +0200 Subject: [PATCH] fix: automatically resume next paused download item after finishing previous one --- .../com/github/libretube/services/DownloadService.kt | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/github/libretube/services/DownloadService.kt b/app/src/main/java/com/github/libretube/services/DownloadService.kt index 378f03470..19a21af1b 100644 --- a/app/src/main/java/com/github/libretube/services/DownloadService.kt +++ b/app/src/main/java/com/github/libretube/services/DownloadService.kt @@ -227,11 +227,17 @@ class DownloadService : LifecycleService() { downloadQueue[item.id] = false - if (_downloadFlow.firstOrNull { it.first == item.id }?.second == DownloadStatus.Stopped) { + if (downloadFlow.firstOrNull { it.first == item.id }?.second == DownloadStatus.Stopped) { downloadQueue.remove(item.id, false) } - stopServiceIfDone() + // start the next download if there are any remaining ones enqueued + val nextDownload = downloadFlow.firstOrNull { (_, status) -> status == DownloadStatus.Paused } + if (nextDownload != null) { + resume(nextDownload.first) + } else { + stopServiceIfDone() + } } private suspend fun progressDownload(