mirror of
https://github.com/mihonapp/mihon.git
synced 2025-11-17 22:47:29 +01:00
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:
@@ -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()
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user