Perform download cache renewal async

Don't block on cache renewals, but notify library on updates so that the badges show up when ready.

We skip the cache when checking if a chapter is downloaded for the reader assuming that it's a
relatively low cost to check for a single chapter.

(Probably) fixes #8254 / fixes #7847
This commit is contained in:
arkon
2022-10-21 15:00:41 -04:00
parent 93925a7286
commit 7e40680af0
6 changed files with 99 additions and 52 deletions
@@ -392,7 +392,7 @@ class ReaderPresenter(
if (chapter.pageLoader is HttpPageLoader) {
val manga = manga ?: return
val dbChapter = chapter.chapter
val isDownloaded = downloadManager.isChapterDownloaded(dbChapter.name, dbChapter.scanlator, manga.title, manga.source)
val isDownloaded = downloadManager.isChapterDownloaded(dbChapter.name, dbChapter.scanlator, manga.title, manga.source, skipCache = true)
if (isDownloaded) {
chapter.state = ReaderChapter.State.Wait
}
@@ -463,6 +463,7 @@ class ReaderPresenter(
nextChapter.scanlator,
manga.title,
manga.source,
skipCache = true,
) || downloadManager.getChapterDownloadOrNull(nextChapter) != null
if (isNextChapterDownloadedOrQueued) {
downloadAutoNextChapters(chaptersNumberToDownload, nextChapter.id, nextChapter.read)
@@ -57,6 +57,7 @@ class ReaderTransitionView @JvmOverloads constructor(context: Context, attrs: At
prevChapter.scanlator,
manga.title,
manga.source,
skipCache = true,
)
val isCurrentDownloaded = transition.from.pageLoader is DownloadPageLoader
binding.upperText.text = buildSpannedString {
@@ -94,6 +95,7 @@ class ReaderTransitionView @JvmOverloads constructor(context: Context, attrs: At
nextChapter.scanlator,
manga.title,
manga.source,
skipCache = true,
)
binding.upperText.text = buildSpannedString {
bold { append(context.getString(R.string.transition_finished)) }