Fix freezing on migrating manga (#7317)

* Use `supend` instead of `runBlocking` in migrate function

* lift `syncChaptersWithSource` out of the db trasaction
This commit is contained in:
jmir1
2022-06-17 05:34:44 +02:00
committed by GitHub
parent 4ef337f1e9
commit 6aee4fc464
2 changed files with 9 additions and 12 deletions

View File

@@ -85,7 +85,7 @@ class SearchPresenter(
}
}
private fun migrateMangaInternal(
private suspend fun migrateMangaInternal(
prevSource: Source?,
source: Source,
sourceChapters: List<SChapter>,
@@ -111,15 +111,15 @@ class SearchPresenter(
flags,
)
try {
syncChaptersWithSource(sourceChapters, manga, source)
} catch (e: Exception) {
// Worst case, chapters won't be synced
}
db.inTransaction {
// Update chapters read
if (migrateChapters) {
try {
syncChaptersWithSource(sourceChapters, manga, source)
} catch (e: Exception) {
// Worst case, chapters won't be synced
}
val prevMangaChapters = db.getChapters(prevManga).executeAsBlocking()
val maxChapterRead = prevMangaChapters
.filter { it.read }