This commit is contained in:
Jobobby04
2020-10-24 22:53:43 -04:00
parent a21d7f4f90
commit 484cb86ca9
4 changed files with 11 additions and 17 deletions
@@ -172,11 +172,11 @@ class SmartSearchEngine(
* @return a manga from the database.
*/
suspend fun networkToLocalManga(sManga: SManga, sourceId: Long): Manga {
var localManga = db.getManga(sManga.url, sourceId).executeAsBlocking()
var localManga = db.getManga(sManga.url, sourceId).await()
if (localManga == null) {
val newManga = Manga.create(sManga.url, sManga.title, sourceId)
newManga.copyFrom(sManga)
val result = db.insertManga(newManga).executeAsBlocking()
val result = db.insertManga(newManga).await()
newManga.id = result.insertedId()
localManga = newManga
}
@@ -17,7 +17,7 @@ import kotlinx.coroutines.launch
class SmartSearchPresenter(private val source: CatalogueSource?, private val config: SourceController.SmartSearchConfig?) :
BasePresenter<SmartSearchController>() {
val scope = CoroutineScope(Job() + Dispatchers.Main)
val scope = CoroutineScope(Job() + Dispatchers.Default)
val smartSearchChannel = Channel<SearchResults>()
@@ -27,7 +27,7 @@ class SmartSearchPresenter(private val source: CatalogueSource?, private val con
super.onCreate(savedState)
if (source != null && config != null) {
scope.launch(Dispatchers.Default) {
scope.launch {
val result = try {
val resultManga = smartSearchEngine.smartSearch(source, config.origTitle)
if (resultManga != null) {