Clean up download ahead logic

- Remove redundant chapter sorting logic when fetching next chapter(s)
- Remove redundant download queue checks (it'll handle already queued or downloaded items)
- Trigger download ahead when read >= 25% of chapter rather than 20%
- Rely on download cache when checking if next chapter is downloaded to avoid jank (fixes #8328)
This commit is contained in:
arkon
2022-10-30 16:59:33 -04:00
parent 725fcbba0e
commit fc184f1cfa
10 changed files with 79 additions and 108 deletions
@@ -271,11 +271,9 @@ class NotificationReceiver : BroadcastReceiver() {
*/
private fun downloadChapters(chapterUrls: Array<String>, mangaId: Long) {
launchIO {
val manga = getManga.await(mangaId)
val manga = getManga.await(mangaId) ?: return@launchIO
val chapters = chapterUrls.mapNotNull { getChapter.await(it, mangaId)?.toDbChapter() }
if (manga != null && chapters.isNotEmpty()) {
downloadManager.downloadChapters(manga, chapters)
}
downloadManager.downloadChapters(manga, chapters)
}
}