mirror of
https://github.com/Suwayomi/Tachidesk.git
synced 2026-01-26 21:44:10 +01:00
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
This commit is contained in:
@@ -119,14 +119,15 @@ object DownloadManager {
|
||||
|
||||
private val notifyFlow = MutableSharedFlow<Unit>(extraBufferCapacity = 1, onBufferOverflow = BufferOverflow.DROP_OLDEST)
|
||||
|
||||
private val statusFlow = MutableSharedFlow<Unit>()
|
||||
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()
|
||||
|
||||
Reference in New Issue
Block a user