From df57070b7026fcf4cf6a219eee8653b8c28ea5be Mon Sep 17 00:00:00 2001 From: schroda <50052685+schroda@users.noreply.github.com> Date: Sat, 9 Dec 2023 01:16:52 +0100 Subject: [PATCH] Make sure to always send finished chapter downloads with the download status (#782) Due to not immediately sending the status, the finished chapters were already removed from the queue by the time the status was actually send to the client. This caused the client to never receive a status with the chapters downloaded flag to be true, resulting in the client to not know that a chapter is downloaded --- .../tachidesk/manga/impl/download/DownloadManager.kt | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/download/DownloadManager.kt b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/download/DownloadManager.kt index b20dc67ff..32a07f846 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/download/DownloadManager.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/download/DownloadManager.kt @@ -119,14 +119,15 @@ object DownloadManager { private val notifyFlow = MutableSharedFlow(extraBufferCapacity = 1, onBufferOverflow = BufferOverflow.DROP_OLDEST) + private val statusFlow = MutableSharedFlow() val status = - notifyFlow.sample(1.seconds) - .onStart { emit(Unit) } + statusFlow.onStart { emit(Unit) } .map { getStatus() } init { scope.launch { notifyFlow.sample(1.seconds).collect { + statusFlow.emit(Unit) sendStatusToAllClients() } } @@ -148,6 +149,10 @@ object DownloadManager { private fun notifyAllClients(immediate: Boolean = false) { scope.launch { notifyFlow.emit(Unit) + + if (immediate) { + statusFlow.emit(Unit) + } } if (immediate) { sendStatusToAllClients()