Send every download status change to the subscriber (#684)

Flow::stateIn has "Strong equality-based conflation" (see documentation).
Thus, it omits every value in case it's equal to the previous one.
Since the DownloadManger::getStatus function returns a status with a queue, that contains all current "DownloadChapters" by reference, the equality check was always true.
Thus, progress changes of downloads were never sent to subscribers.
Subscriber were only notified about finished downloads (size of queue changed) or downloader status changes
This commit is contained in:
schroda
2023-09-16 19:07:43 +02:00
committed by GitHub
parent 7086055ec3
commit c9423ef425
2 changed files with 10 additions and 8 deletions

View File

@@ -1,11 +1,16 @@
package suwayomi.tachidesk.graphql.queries
import kotlinx.coroutines.flow.first
import suwayomi.tachidesk.graphql.types.DownloadStatus
import suwayomi.tachidesk.manga.impl.download.DownloadManager
import suwayomi.tachidesk.server.JavalinSetup.future
import java.util.concurrent.CompletableFuture
class DownloadQuery {
fun downloadStatus(): DownloadStatus {
return DownloadStatus(DownloadManager.status.value)
fun downloadStatus(): CompletableFuture<DownloadStatus> {
return future {
DownloadStatus(DownloadManager.status.first())
}
}
}