Inline DownloadQueue into Downloader (#9159)

* Move statusFlow and progressFlow to DownloadManager

* Inline DownloadQueue into Downloader

* Move reorderQueue implementation to Downloader
This commit is contained in:
Two-Ai
2023-02-28 22:13:13 -05:00
committed by GitHub
parent f03a834136
commit b41565f879
7 changed files with 134 additions and 151 deletions

View File

@@ -111,7 +111,7 @@ class DownloadQueueScreenModel(
init {
coroutineScope.launch {
downloadManager.queue.state
downloadManager.queueState
.map { downloads ->
downloads
.groupBy { it.source }
@@ -136,8 +136,8 @@ class DownloadQueueScreenModel(
val isDownloaderRunning
get() = downloadManager.isDownloaderRunning
fun getDownloadStatusFlow() = downloadManager.queue.statusFlow()
fun getDownloadProgressFlow() = downloadManager.queue.progressFlow()
fun getDownloadStatusFlow() = downloadManager.statusFlow()
fun getDownloadProgressFlow() = downloadManager.progressFlow()
fun startDownloads() {
downloadManager.startDownloads()

View File

@@ -427,7 +427,7 @@ class MangaInfoScreenModel(
private fun observeDownloads() {
coroutineScope.launchIO {
downloadManager.queue.statusFlow()
downloadManager.statusFlow()
.filter { it.manga.id == successState?.manga?.id }
.catch { error -> logcat(LogPriority.ERROR, error) }
.collect {
@@ -438,7 +438,7 @@ class MangaInfoScreenModel(
}
coroutineScope.launchIO {
downloadManager.queue.progressFlow()
downloadManager.progressFlow()
.filter { it.manga.id == successState?.manga?.id }
.catch { error -> logcat(LogPriority.ERROR, error) }
.collect {

View File

@@ -94,7 +94,7 @@ private class MoreScreenModel(
coroutineScope.launchIO {
combine(
downloadManager.isDownloaderRunning,
downloadManager.queue.state,
downloadManager.queueState,
) { isRunning, downloadQueue -> Pair(isRunning, downloadQueue.size) }
.collectLatest { (isDownloading, downloadQueueSize) ->
val pendingDownloadExists = downloadQueueSize != 0

View File

@@ -99,7 +99,7 @@ class UpdatesScreenModel(
}
coroutineScope.launchIO {
merge(downloadManager.queue.statusFlow(), downloadManager.queue.progressFlow())
merge(downloadManager.statusFlow(), downloadManager.progressFlow())
.catch { logcat(LogPriority.ERROR, it) }
.collect(this@UpdatesScreenModel::updateDownloadState)
}