-
Notifications
You must be signed in to change notification settings - Fork 169
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Performance refactors for Posts feed #1527
Conversation
# Conflicts: # app/build.gradle.kts # app/src/main/java/com/jerboa/ui/components/home/HomeActivity.kt
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check the comments below, but my biggest concern is the fact that there are now two lists to keep track of, rather than a single snapshotstatelist.
Also the remembers are potentially bug-worthy, since source data changes might not be reflected properly. If they're necessary that's okay, but maybe they should be keyed.
app/src/main/java/com/jerboa/ui/components/community/CommunityLink.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/com/jerboa/ui/components/home/HomeActivity.kt
Outdated
Show resolved
Hide resolved
# Conflicts: # app/src/main/java/com/jerboa/model/PostsViewModel.kt
# Conflicts: # app/src/main/java/com/jerboa/ui/components/post/PostListing.kt # app/src/main/java/com/jerboa/ui/components/post/composables/PostOptionsDropdown.kt
# Conflicts: # app/src/main/java/com/jerboa/ui/components/community/CommunityActivity.kt # app/src/main/java/com/jerboa/ui/components/home/HomeActivity.kt # app/src/main/java/com/jerboa/ui/components/post/PostActivity.kt # app/src/main/java/com/jerboa/ui/components/post/PostListings.kt
Refactor to use
SnapshotStateList
instead ofList
Before what we did was create a new list each time we change something in that list. Since compose checks on equality the list is now different and fully recomposes the entire list. Instead use
SnapshotStateList
which emits events for only the changes made to the list.Many changes have made to the postlisting so that when a vote changes it doesn't recompose the entire postlisting but just the votes. This was only successful for postlisting as the card modes use postview to deeply into the "onAction" lambdas which trigger recompose as the postview has different equality.
It no longer recomposes the feed when adding/updating postviews
The collapsible header also causes recompositions as it changes the innerpadding which is applied to the lazy column. Not sure if anything can be done for that. (But only when it moves, so when u scroll down once its up, no recompositions happen)(This has been solved)I am also going to refactor the comments. (I'll do that in a separate PR)