Using a global scope to delete chapters

This commit is contained in:
Jays2Kings 2021-05-11 15:24:51 -04:00
parent 887d2fb293
commit 80c127bc10
4 changed files with 13 additions and 8 deletions

View File

@ -796,7 +796,7 @@ class LibraryPresenter(
/** Remove manga from the library and delete the downloads */
fun confirmDeletion(mangas: List<Manga>) {
presenterScope.launch {
launchIO {
val mangaToDelete = mangas.distinctBy { it.id }
mangaToDelete.forEach { manga ->
coverCache.deleteFromCache(manga)

View File

@ -303,7 +303,7 @@ class MangaDetailsPresenter(
* @param chapters the list of chapters to delete.
*/
fun deleteChapters(chapters: List<ChapterItem>, update: Boolean = true, isEverything: Boolean = false) {
scope.launchIO {
launchIO {
if (isEverything) {
downloadManager.deleteManga(manga, source)
} else {
@ -583,7 +583,7 @@ class MangaDetailsPresenter(
}
fun confirmDeletion() {
scope.launchIO {
launchIO {
coverCache.deleteFromCache(manga)
customMangaManager.saveMangaInfo(CustomMangaManager.MangaJson(manga.id!!))
downloadManager.deleteManga(manga, source)

View File

@ -17,6 +17,7 @@ import eu.kanade.tachiyomi.data.preference.PreferencesHelper
import eu.kanade.tachiyomi.source.SourceManager
import eu.kanade.tachiyomi.ui.base.presenter.BaseCoroutinePresenter
import eu.kanade.tachiyomi.util.system.executeOnIO
import eu.kanade.tachiyomi.util.system.launchIO
import eu.kanade.tachiyomi.util.system.launchUI
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job
@ -400,8 +401,9 @@ class RecentsPresenter(
*/
fun deleteChapter(chapter: Chapter, manga: Manga, update: Boolean = true) {
val source = Injekt.get<SourceManager>().getOrStub(manga.source)
downloadManager.deleteChapters(listOf(chapter), manga, source)
launchIO {
downloadManager.deleteChapters(listOf(chapter), manga, source)
}
if (update) {
val item = recentItems.find { it.chapter.id == chapter.id } ?: return
item.apply {

View File

@ -28,6 +28,7 @@ import eu.kanade.tachiyomi.ui.source.filter.TextItem
import eu.kanade.tachiyomi.ui.source.filter.TextSectionItem
import eu.kanade.tachiyomi.ui.source.filter.TriStateItem
import eu.kanade.tachiyomi.ui.source.filter.TriStateSectionItem
import eu.kanade.tachiyomi.util.system.launchIO
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job
@ -294,9 +295,11 @@ open class BrowseSourcePresenter(
}
fun confirmDeletion(manga: Manga) {
coverCache.deleteFromCache(manga)
val downloadManager: DownloadManager = Injekt.get()
downloadManager.deleteManga(manga, source)
launchIO {
coverCache.deleteFromCache(manga)
val downloadManager: DownloadManager = Injekt.get()
downloadManager.deleteManga(manga, source)
}
}
/**