From 02bac319b8940c753c67d23af87c8a30d087c1c0 Mon Sep 17 00:00:00 2001 From: Bnyro Date: Tue, 26 Sep 2023 13:12:32 +0200 Subject: [PATCH] fix: buggy icon to pause download --- .../com/github/libretube/services/DownloadService.kt | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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 2caeee182..98689be01 100644 --- a/app/src/main/java/com/github/libretube/services/DownloadService.kt +++ b/app/src/main/java/com/github/libretube/services/DownloadService.kt @@ -245,11 +245,14 @@ class DownloadService : LifecycleService() { } setPauseNotification(notificationBuilder, item, completed) - pause(item.id) + + downloadQueue[item.id] = false if (_downloadFlow.firstOrNull { it.first == item.id }?.second == DownloadStatus.Stopped) { downloadQueue.remove(item.id, false) } + + stopServiceIfDone() } private suspend fun startConnection( @@ -331,6 +334,10 @@ class DownloadService : LifecycleService() { fun pause(id: Int) { downloadQueue[id] = false + lifecycleScope.launch(coroutineContext) { + _downloadFlow.emit(id to DownloadStatus.Paused) + } + stopServiceIfDone() }