mirror of
				https://github.com/mihonapp/mihon.git
				synced 2025-10-31 22:37:56 +01:00 
			
		
		
		
	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:
		| @@ -39,6 +39,7 @@ import eu.kanade.presentation.library.components.LibraryToolbarTitle | ||||
| import eu.kanade.tachiyomi.R | ||||
| import eu.kanade.tachiyomi.data.cache.CoverCache | ||||
| import eu.kanade.tachiyomi.data.database.models.toDomainManga | ||||
| import eu.kanade.tachiyomi.data.download.DownloadCache | ||||
| import eu.kanade.tachiyomi.data.download.DownloadManager | ||||
| import eu.kanade.tachiyomi.data.track.TrackManager | ||||
| import eu.kanade.tachiyomi.source.SourceManager | ||||
| @@ -88,6 +89,7 @@ class LibraryPresenter( | ||||
|     private val coverCache: CoverCache = Injekt.get(), | ||||
|     private val sourceManager: SourceManager = Injekt.get(), | ||||
|     private val downloadManager: DownloadManager = Injekt.get(), | ||||
|     private val downloadCache: DownloadCache = Injekt.get(), | ||||
|     private val trackManager: TrackManager = Injekt.get(), | ||||
| ) : BasePresenter<LibraryController>(), LibraryState by state { | ||||
|  | ||||
| @@ -338,7 +340,8 @@ class LibraryPresenter( | ||||
|         val libraryMangasFlow = combine( | ||||
|             getLibraryManga.subscribe(), | ||||
|             libraryPreferences.downloadBadge().changes(), | ||||
|         ) { libraryMangaList, downloadBadgePref -> | ||||
|             downloadCache.changes, | ||||
|         ) { libraryMangaList, downloadBadgePref, _ -> | ||||
|             libraryMangaList | ||||
|                 .map { libraryManga -> | ||||
|                     // Display mode based on user preference: take it from global library setting or category | ||||
|   | ||||
| @@ -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)) } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user