jerboa
jerboa copied to clipboard
Unwanted behaviour loading new posts
Jerboa Version The one in main
Describe the bug If you scroll down and it loads new posts it will also show the refresh thingy (had to slow down my device to properly make it visible)
If you scroll down it should only show the loading bar not the pullrefresh indicator (this also causes unnecessary recomposisitions)
Example show casing it https://github.com/dessalines/jerboa/assets/67873169/fbc4b76b-efa7-4dc6-8cfc-dac156b59701
Full view example https://github.com/dessalines/jerboa/assets/67873169/be42fbac-b152-4dbb-983a-2dfb166616ce
To Reproduce Steps to reproduce the behavior:
Just scroll the main feed.
Relevant code bits
val loading = communityViewModel.postsRes == ApiState.Loading || communityViewModel.fetchingMore
val pullRefreshState = rememberPullRefreshState(
refreshing = loading,
onRefresh = {
when (val communityRes = communityViewModel.communityRes) {
is ApiState.Success -> {
communityViewModel.resetPage()
communityViewModel.getPosts(
form =
GetPosts(
community_id = communityRes.data.community_view.community.id,
page = communityViewModel.page,
sort = communityViewModel.sortType,
auth = account?.jwt,
),
)
}
else -> {}
}
},
)
....
PullRefreshIndicator(loading, pullRefreshState, Modifier.align(Alignment.TopCenter))
// Can't be in ApiState.Loading, because of infinite scrolling
if (loading) {
LoadingBar(padding = padding)
}
Both share the same loading variable that controls the visibility state. But PullRefreshIndicator should only show if you actually wanna refresh the feed not load in more posts. I assume this might be in different places too.