-
Notifications
You must be signed in to change notification settings - Fork 984
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
fix: avoid re-renders inside contact-list for new-chat sheet #21640
base: develop
Are you sure you want to change the base?
Conversation
Jenkins BuildsClick to see older builds (16)
|
014f446
to
7021d5e
Compare
Hi @seanstrom ! Thank you for this PR. The avatar component blinks all over the app, I was recently working in the onboarding and found the avatar is using:
but I don't think that approach is being effective. I also noticed this avatar rerender flickering in my latest PR:
About the solution, I have several things to say. A We could check what are the dependencies causing the re-renders and fix them (or directly fix the wrapper). Otherwise, even though the flat-list items are being re-rendered, the avatar is receiving the exact same props, so we are probably passing some extra data that is causing the re-render. So, I'd say the root cause and solution both rely in a deeper issue. WDYT? |
7021d5e
to
85cab42
Compare
@ulisesmac I decided to take a deeper look at what was happening inside these components based on your feedback. There seems to be a variety of issues, which I've tried to address in some new changes. For example:
Thank you again for the feedback! It helped uncover some weird glitches that may now be resolved, and it seems we can even keep using |
5e52f2e
to
afe90d0
Compare
(let [data (flatten-sections sections)] | ||
(let [data (flatten-sections sections) | ||
render-item (rn/use-callback | ||
(fn [p1 p2 p3 p4] |
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.
What is p4
if there are only 3 deps?
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.
So I think p1
p2
p3
p4
are the arguments that are passed to the render function. So in this case p1
is the item in the list, p2
is the index, p3
is a reference to the separators in the list, and p4
is the render-data that's passed from the list component.
More details can be found here:
status-mobile/src/react_native/flat_list.cljs
Lines 8 to 13 in afe90d0
(defn- wrap-render-fn | |
[f render-data] | |
(fn [^js data] | |
(reagent/as-element [f (.-item data) (.-index data) | |
(.-separators data) render-data | |
(.-isActive data) (.-drag data)]))) |
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.
Thanks, my brain farted and was confused with use-callback
.
:render-fn render-fn | ||
:scroll-enabled @scroll-enabled? | ||
:render-fn contact-item-render | ||
:render-data {:set-has-error set-has-error} |
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.
This is exactly the fix I found here #21658 (comment) coincidentally. Thanks for the fix @seanstrom
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.
And the same I'm applying in my WIP for:
@seanstrom Are you fixing all the avatar usages in this PR or just this one? I'm asking because we don't want to duplicate work
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.
This PR is only intending to fix the usage of the reloading of the avatar images inside the contact-list view for a new-chat, but it's possible that some of the changes related to the image source uri will affect other usages too.
Great! seems you've found the underlying issues 🎉 For:
This is what I was recently talking about with @ilmotta, at the end seems problems are related to passing unstable references. Let's just be careful about adding extra complexity to the implementations, just in case that happens.
Great finding! |
@ulisesmac @seanstrom I don't see the |
… the formatting function, now allow these clock timestamps to be passed as props
afe90d0
to
d98de2e
Compare
fixes #20532
Summary
:scroll-enabled
tofalse
. However, when this prop is changed the scroll-view will re-render all the list items, which can cause the contact images to flicker and it seems to interfere with selecting a contact.scroll-enabled
reagent atom:status-mobile/src/status_im/common/bottom_sheet_screen/view.cljs
Lines 16 to 36 in 014f446
scroll-enabled
for the contact list, which solves the re-rendering issue, but does not allow the drag gesture to override the scroll gesture.Platforms
Areas that maybe impacted
Functional
Steps to test
Before and after screenshots comparison
Note, that in these screen recordings I've intentionally duplicated my contacts in the contact list because I didn't have enough contacts added to my profiles. So that's why there's repeated data and multiple items selected when selecting a single contact.
Screen.Recording.2024-11-19.at.13.02.38.mov
Screen.Recording.2024-11-19.at.13.01.56.mov
Screen.Recording.2024-11-19.at.12.56.12.mov
Screen.Recording.2024-11-19.at.12.54.51.mov
status: ready