Code review:
refactor(discover): restore exhaustive when in DiscoverTab.toTabIndex refactor(discover): collapse DiscoverTab.toTabIndex to ordinal and drop redundant pager guards
This commit is contained in:
+2
-5
@@ -189,10 +189,7 @@ fun DiscoverScreen(
|
|||||||
val pagerState = rememberForeverPagerState(key = PagerStateKeys.DISCOVER_SCREEN) { feedTabs.size }
|
val pagerState = rememberForeverPagerState(key = PagerStateKeys.DISCOVER_SCREEN) { feedTabs.size }
|
||||||
|
|
||||||
LaunchedEffect(initialTab) {
|
LaunchedEffect(initialTab) {
|
||||||
val target = initialTab?.toTabIndex() ?: return@LaunchedEffect
|
initialTab?.let { pagerState.scrollToPage(it.toTabIndex()) }
|
||||||
if (target in feedTabs.indices && pagerState.currentPage != target) {
|
|
||||||
pagerState.scrollToPage(target)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
WatchAccountForDiscoveryScreen(
|
WatchAccountForDiscoveryScreen(
|
||||||
@@ -538,7 +535,7 @@ private fun DiscoverFeedColumnsLoaded(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tab positions match the order built in DiscoverScreen above. Update both together.
|
// Exhaustive on DiscoverTab so adding a new enum value forces an update of feedTabs above.
|
||||||
private fun DiscoverTab.toTabIndex(): Int =
|
private fun DiscoverTab.toTabIndex(): Int =
|
||||||
when (this) {
|
when (this) {
|
||||||
DiscoverTab.FOLLOWS -> 0
|
DiscoverTab.FOLLOWS -> 0
|
||||||
|
|||||||
Reference in New Issue
Block a user