mirror of
https://github.com/mihonapp/mihon.git
synced 2024-12-24 18:08:24 +01:00
Open migrated/copied MangaController right away (#5005)
This commit is contained in:
parent
7ba43ae5c2
commit
818468c58f
@ -6,6 +6,7 @@ import androidx.core.view.isVisible
|
||||
import com.afollestad.materialdialogs.MaterialDialog
|
||||
import com.afollestad.materialdialogs.list.listItemsMultiChoice
|
||||
import com.bluelinelabs.conductor.Controller
|
||||
import com.bluelinelabs.conductor.RouterTransaction
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
@ -15,6 +16,7 @@ import eu.kanade.tachiyomi.ui.base.controller.withFadeTransaction
|
||||
import eu.kanade.tachiyomi.ui.browse.migration.MigrationFlags
|
||||
import eu.kanade.tachiyomi.ui.browse.source.globalsearch.GlobalSearchController
|
||||
import eu.kanade.tachiyomi.ui.browse.source.globalsearch.GlobalSearchPresenter
|
||||
import eu.kanade.tachiyomi.ui.manga.MangaController
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
|
||||
class SearchController(
|
||||
@ -69,12 +71,14 @@ class SearchController(
|
||||
super.onMangaClick(manga)
|
||||
}
|
||||
|
||||
fun renderIsReplacingManga(isReplacingManga: Boolean) {
|
||||
if (isReplacingManga) {
|
||||
binding.progress.isVisible = true
|
||||
} else {
|
||||
binding.progress.isVisible = false
|
||||
fun renderIsReplacingManga(isReplacingManga: Boolean, newManga: Manga?) {
|
||||
binding.progress.isVisible = isReplacingManga
|
||||
if (!isReplacingManga) {
|
||||
router.popController(this)
|
||||
if (newManga != null) {
|
||||
// Replaces old MangaController
|
||||
router.replaceTopController(RouterTransaction.with(MangaController(newManga)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -26,12 +26,16 @@ class SearchPresenter(
|
||||
private val manga: Manga
|
||||
) : GlobalSearchPresenter(initialQuery) {
|
||||
|
||||
private val replacingMangaRelay = BehaviorRelay.create<Boolean>()
|
||||
private val replacingMangaRelay = BehaviorRelay.create<Pair<Boolean, Manga?>>()
|
||||
|
||||
override fun onCreate(savedState: Bundle?) {
|
||||
super.onCreate(savedState)
|
||||
|
||||
replacingMangaRelay.subscribeLatestCache({ controller, isReplacingManga -> (controller as? SearchController)?.renderIsReplacingManga(isReplacingManga) })
|
||||
replacingMangaRelay.subscribeLatestCache(
|
||||
{ controller, (isReplacingManga, newManga) ->
|
||||
(controller as? SearchController)?.renderIsReplacingManga(isReplacingManga, newManga)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
override fun getEnabledSources(): List<CatalogueSource> {
|
||||
@ -55,7 +59,7 @@ class SearchPresenter(
|
||||
fun migrateManga(prevManga: Manga, manga: Manga, replace: Boolean) {
|
||||
val source = sourceManager.get(manga.source) ?: return
|
||||
|
||||
replacingMangaRelay.call(true)
|
||||
replacingMangaRelay.call(Pair(true, null))
|
||||
|
||||
presenterScope.launchIO {
|
||||
try {
|
||||
@ -67,7 +71,7 @@ class SearchPresenter(
|
||||
withUIContext { view?.applicationContext?.toast(e.message) }
|
||||
}
|
||||
|
||||
presenterScope.launchUI { replacingMangaRelay.call(false) }
|
||||
presenterScope.launchUI { replacingMangaRelay.call(Pair(false, manga)) }
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user