From f51e32f39b192bcbd1d66dfd937e569b8248b5d2 Mon Sep 17 00:00:00 2001 From: arkon Date: Sun, 28 Feb 2021 16:25:48 -0500 Subject: [PATCH] Avoid crash during migration --- .../ui/browse/migration/search/SearchPresenter.kt | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/migration/search/SearchPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/migration/search/SearchPresenter.kt index f875c93f2c..9f15d2add8 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/migration/search/SearchPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/migration/search/SearchPresenter.kt @@ -17,6 +17,8 @@ import eu.kanade.tachiyomi.ui.browse.source.globalsearch.GlobalSearchPresenter import eu.kanade.tachiyomi.util.chapter.syncChaptersWithSource import eu.kanade.tachiyomi.util.lang.launchIO import eu.kanade.tachiyomi.util.lang.launchUI +import eu.kanade.tachiyomi.util.lang.withUIContext +import eu.kanade.tachiyomi.util.system.toast import java.util.Date class SearchPresenter( @@ -56,11 +58,15 @@ class SearchPresenter( replacingMangaRelay.call(true) presenterScope.launchIO { - val chapters = source.getChapterList(manga.toMangaInfo()) - .map { it.toSChapter() } + try { + val chapters = source.getChapterList(manga.toMangaInfo()) + .map { it.toSChapter() } + + migrateMangaInternal(source, chapters, prevManga, manga, replace) + } catch (e: Throwable) { + withUIContext { view?.applicationContext?.toast(e.message) } + } - migrateMangaInternal(source, chapters, prevManga, manga, replace) - }.invokeOnCompletion { presenterScope.launchUI { replacingMangaRelay.call(false) } } }