Instantly show check on tab for tracked manga

This commit is contained in:
Jay 2020-01-21 18:04:23 -08:00
parent 2b1752de09
commit 343fad39b6

View file

@ -144,10 +144,22 @@ class MangaController : RxController, TabbedController {
super.onChangeStarted(handler, type)
if (type.isEnter) {
tabLayout()?.setupWithViewPager(manga_pager)
checkInitialTrackState()
trackingIconSubscription = trackingIconRelay.subscribe { setTrackingIconInternal(it) }
}
}
private fun checkInitialTrackState() {
val manga = manga ?: return
val loggedServices by lazy { Injekt.get<TrackManager>().services.filter { it.isLogged } }
val db = Injekt.get<DatabaseHelper>()
val tracks = db.getTracks(manga).executeAsBlocking()
if (loggedServices.any { service -> tracks.any { it.sync_id == service.id } }) {
setTrackingIcon(true)
}
}
fun tabLayout():TabLayout? {
return if (activity is SearchActivity) activity?.sTabs
else activity?.tabs