diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadCache.kt b/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadCache.kt index 4741d47282..d38a2318f9 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadCache.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadCache.kt @@ -75,11 +75,9 @@ class DownloadCache( checkRenew() - val files = mangaFiles[manga.id]?.toSet() ?: return false - return files.any { file -> - provider.getValidChapterDirNames(chapter).any { - it.toLowerCase() == file.toLowerCase() - } + val files = mangaFiles[manga.id]?.toHashSet() ?: return false + return provider.getValidChapterDirNames(chapter).any { + it in files } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaDetailsPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaDetailsPresenter.kt index 8fcf37389f..3634df9064 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaDetailsPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaDetailsPresenter.kt @@ -82,25 +82,32 @@ class MangaDetailsPresenter( var headerItem = MangaHeaderItem(manga, controller.fromCatalogue) fun onCreate() { - - isLockedFromSearch = SecureActivityDelegate.shouldBeLocked() - headerItem.isLocked = isLockedFromSearch - downloadManager.addListener(this) - LibraryUpdateService.setListener(this) - tracks = db.getTracks(manga).executeAsBlocking() - if (manga.source == LocalSource.ID) { - refreshAll() - } else if (!manga.initialized) { - isLoading = true - controller.setRefresh(true) - controller.updateHeader() - refreshAll() - } else { - updateChapters() - controller.updateChapters(this.chapters) + scope.launch { + withContext(Dispatchers.IO) { + isLockedFromSearch = SecureActivityDelegate.shouldBeLocked() + headerItem.isLocked = isLockedFromSearch + downloadManager.addListener(this@MangaDetailsPresenter) + LibraryUpdateService.setListener(this@MangaDetailsPresenter) + tracks = db.getTracks(manga).executeAsBlocking() + if (manga.source == LocalSource.ID) { + refreshAll() + } else if (!manga.initialized) { + isLoading = true + withContext(Dispatchers.Main) { + controller.setRefresh(true) + controller.updateHeader() + } + refreshAll() + } else { + updateChapters() + withContext(Dispatchers.Main) { + controller.updateChapters(this@MangaDetailsPresenter.chapters) + } + } + setTrackItems() + refreshTracking(false) + } } - setTrackItems() - refreshTracking(false) } fun onDestroy() {