From 343fad39b69131c178cfe67adca344966b4fa765 Mon Sep 17 00:00:00 2001 From: Jay Date: Tue, 21 Jan 2020 18:04:23 -0800 Subject: [PATCH] Instantly show check on tab for tracked manga --- .../eu/kanade/tachiyomi/ui/manga/MangaController.kt | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaController.kt index 39d996b6b4..0b31f0f191 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaController.kt @@ -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().services.filter { it.isLogged } } + val db = Injekt.get() + 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