mirror of
https://github.com/msfjarvis/compose-lobsters.git
synced 2024-06-03 04:18:58 +05:30
fix(android): only attempt to scroll when items exist
Fixes COMPOSE-LOBSTERS-3F
This commit is contained in:
parent
9357362ef6
commit
1fff9d9aa2
|
@ -129,7 +129,9 @@ fun LobstersPostsScreen(
|
|||
icon = Icons.Outlined.Whatshot,
|
||||
selectedIcon = Icons.Filled.Whatshot,
|
||||
) {
|
||||
coroutineScope.launch { hottestListState.animateScrollToItem(index = 0) }
|
||||
coroutineScope.launch {
|
||||
if (hottestPosts.itemCount > 0) hottestListState.animateScrollToItem(index = 0)
|
||||
}
|
||||
},
|
||||
NavigationItem(
|
||||
label = "Newest",
|
||||
|
@ -137,7 +139,9 @@ fun LobstersPostsScreen(
|
|||
icon = Icons.Outlined.NewReleases,
|
||||
selectedIcon = Icons.Filled.NewReleases,
|
||||
) {
|
||||
coroutineScope.launch { newestListState.animateScrollToItem(index = 0) }
|
||||
coroutineScope.launch {
|
||||
if (newestPosts.itemCount > 0) newestListState.animateScrollToItem(index = 0)
|
||||
}
|
||||
},
|
||||
NavigationItem(
|
||||
label = "Saved",
|
||||
|
@ -145,7 +149,9 @@ fun LobstersPostsScreen(
|
|||
icon = Icons.Outlined.FavoriteBorder,
|
||||
selectedIcon = Icons.Filled.Favorite,
|
||||
) {
|
||||
coroutineScope.launch { savedListState.animateScrollToItem(index = 0) }
|
||||
coroutineScope.launch {
|
||||
if (savedPosts.isNotEmpty()) savedListState.animateScrollToItem(index = 0)
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user