From 54a26bf7d097648fa412d279b311e2d374cfb92a Mon Sep 17 00:00:00 2001 From: Ahmad Ansori Palembani Date: Sun, 9 Jun 2024 14:24:09 +0700 Subject: [PATCH] fix: Don't use runBlocking --- .../eu/kanade/tachiyomi/util/chapter/ChapterSourceSync.kt | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/util/chapter/ChapterSourceSync.kt b/app/src/main/java/eu/kanade/tachiyomi/util/chapter/ChapterSourceSync.kt index 90fa9ec22b..31080958c3 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/util/chapter/ChapterSourceSync.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/util/chapter/ChapterSourceSync.kt @@ -9,7 +9,6 @@ import eu.kanade.tachiyomi.source.Source import eu.kanade.tachiyomi.source.model.SChapter import eu.kanade.tachiyomi.source.online.HttpSource import eu.kanade.tachiyomi.util.chapter.ChapterFilter.Companion.filterChaptersByScanlators -import kotlinx.coroutines.runBlocking import uy.kohesive.injekt.injectLazy import java.util.Date import java.util.TreeSet @@ -23,7 +22,7 @@ import java.util.TreeSet * @param source the source of the chapters. * @return a pair of new insertions and deletions. */ -fun syncChaptersWithSource( +suspend fun syncChaptersWithSource( db: DatabaseHelper, rawSourceChapters: List, manga: Manga, @@ -36,7 +35,7 @@ fun syncChaptersWithSource( val downloadManager: DownloadManager by injectLazy() val getChapters: GetChapters by injectLazy() // Chapters from db. - val dbChapters = runBlocking { getChapters.await(manga, false) } + val dbChapters = getChapters.await(manga, false) val sourceChapters = rawSourceChapters .distinctBy { it.url } @@ -161,7 +160,7 @@ fun syncChaptersWithSource( db.fixChaptersSourceOrder(sourceChapters).executeAsBlocking() // Set this manga as updated since chapters were changed - val newestChapterDate = runBlocking { getChapters.await(manga, false) } + val newestChapterDate = getChapters.await(manga, false) .maxOfOrNull { it.date_upload } ?: 0L if (newestChapterDate == 0L) { if (toAdd.isNotEmpty()) {