mihon/app/src/main/java/eu/kanade/tachiyomi
Two-Ai 3ae1e37c40
Replace RxJava in Downloader (#9256)
* Rename removeFromQueueByPredicate to removeFromQueueIf

Follow-up to PR comment in #9511

* Make Download hashCode stable

Mutating pages would previously change the Download hashCode, which
breaks HashMap lookups.

* Convert Donwloader subscription to coroutine

Replace downloadsRelay with activeDownloadsFlow. Instead of managing
a PublishRelay independent from the queue, derive a Flow of active
downloads directly from the queue StateFlow. (This will allow
updating the queue without pausing the downloader, to be done in a
follow-up PR.)

When a download completes successfully, the downloads is removed from
queueState. This updates activeDownloadsFlow and causes the
downloaderJob start the download job for the next active download.

When a download fails, the download is left in the queue, so
queueState is not modified. To make activeDownloadsFlow update
without a change to queueState, use transformLatest and use the
Download statusFlows to suspend until a download reaches the ERROR
state.

To avoid stopping and starting downloads every time
activeDownloadsFlow emits a new value, maintain a map of current
download Jobs and only start/stop jobs in the difference between
downloadJobs and activeDownloads. To make sure all child download
jobs are cancelled when the top-level downloader job is cancelled,
use supervisorScope.

* Remove obsolete main thread references in Downloader

Thread safety of the queue state used to be guaranteed by running all
queue mutation on the main thread, but this has not been true for
some time. Since the queue state is now backed by a StateFlow,
queueState can be safely updated by any thread.
2023-05-24 18:02:27 -04:00
..
crash Move more things around 2023-01-27 22:31:12 -05:00
data Replace RxJava in Downloader (#9256) 2023-05-24 18:02:27 -04:00
extension Remove SourceData and use StubSource directly for database (#9429) 2023-05-03 10:33:05 -04:00
source Avoid attempts to renaming download dirs if name hasn't actually changed 2023-05-14 12:24:40 -04:00
ui Upgrade Compose 2023-05-21 11:21:32 -04:00
util Migrate reader slider and next/prev buttons to Compose 2023-05-03 17:14:11 -04:00
widget Minor cleanup 2023-04-23 10:11:26 -04:00
App.kt Enable predictive back gesture for Android 13 (behind developer option)/14+ 2023-05-20 16:16:19 -04:00
AppInfo.kt extension-lib 1.5: Add AppInfo#getSupportedImageMimeTypes() 2023-04-28 11:36:17 -04:00
AppModule.kt Move more things to domain/data modules 2023-03-07 22:38:02 -05:00
Migrations.kt Upgrade Compose 2023-05-21 11:21:32 -04:00