fix: Don't use runBlocking

This commit is contained in:
Ahmad Ansori Palembani 2024-06-09 14:36:21 +07:00
parent 54a26bf7d0
commit 2218804d58
Signed by: null2264
GPG key ID: BA64F8B60AF3EFB6
2 changed files with 5 additions and 6 deletions

View file

@ -1298,7 +1298,7 @@ class LibraryPresenter(
presenterScope.launch {
withContext(Dispatchers.IO) {
mangaList.forEach { list ->
val chapters = runBlocking { getChapters.await(list) }.filter { !it.read }
val chapters = getChapters.await(list).filter { !it.read }
downloadManager.downloadChapters(list, chapters)
}
}

View file

@ -33,7 +33,6 @@ import kotlinx.coroutines.flow.drop
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.withContext
import uy.kohesive.injekt.Injekt
import uy.kohesive.injekt.api.get
@ -455,13 +454,13 @@ class RecentsPresenter(
return Triple(sortedChapters, firstChapter, extraCount)
}
private fun getNextChapter(manga: Manga): Chapter? {
val chapters = runBlocking { getChapters.await(manga) }
private suspend fun getNextChapter(manga: Manga): Chapter? {
val chapters = getChapters.await(manga)
return ChapterSort(manga, chapterFilter, preferences).getNextUnreadChapter(chapters, false)
}
private fun getFirstUpdatedChapter(manga: Manga, chapter: Chapter): Chapter? {
val chapters = runBlocking { getChapters.await(manga) }
private suspend fun getFirstUpdatedChapter(manga: Manga, chapter: Chapter): Chapter? {
val chapters = getChapters.await(manga)
return chapters
.sortedWith(ChapterSort(manga, chapterFilter, preferences).sortComparator(true)).find {
!it.read && abs(it.date_fetch - chapter.date_fetch) <= TimeUnit.HOURS.toMillis(12)