-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
[🐴] Additional tweaks to the message list #4075
Conversation
Your Render PR Server URL is https://social-app-pr-4075.onrender.com. Follow its progress at https://dashboard.render.com/web/srv-cp3du7uct0pc73eljv6g. |
const [hasInitiallyRendered, setHasInitiallyRendered] = React.useState(false) | ||
|
||
// HACK: Because we need to scroll to the bottom of the list once initial items are added to the list, we also have | ||
// to take into account that scrolling to the end of the list on native will happen asynchronously. This will cause | ||
// a little flicker when the items are first renedered at the top and immediately scrolled to the bottom. to prevent | ||
// this, we will wait until the first render has completed to remove the loading overlay. | ||
React.useEffect(() => { | ||
if ( | ||
!hasInitiallyRendered && | ||
isConvoActive(convoState) && | ||
!convoState.isFetchingHistory | ||
) { | ||
setTimeout(() => { | ||
setHasInitiallyRendered(true) | ||
}, 15) | ||
} | ||
}, [convoState, hasInitiallyRendered]) |
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 was a nasty hack, time to rm
|
// Since we are using the native web methods for scrolling on `List`, we only use the reanimated `scrollTo` on native | ||
const scrollToOffset = React.useCallback( | ||
(offset: number, animated: boolean) => { | ||
if (isWeb) { | ||
flatListRef.current?.scrollToOffset({offset, animated}) | ||
} else { | ||
runOnUI(scrollTo)(flatListRef, 0, offset, animated) | ||
} | ||
}, | ||
[flatListRef], | ||
) | ||
|
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.
In a galaxy far far away, developers have a Javascript ecosystem that interacts with native code fully synchronously, and they live very happily.
Alas, that is not our galaxy. There's some layouts that are not actually ready yet when we call scrollTo
right now, particularly around sending a new message and expecting the view to scroll up. We've seen over the past week that the old way of doing things was solid, so let's return to that.
We will still use scrollTo
for keyboard animation scrolling, because its 🔥🥵🔥 and doesn't cause problems.
another nit nit small annoyance add a comment only use `scrollTo` when necessary remove now unnecessary styles
* origin/main: [🐴] Don't always show notification for everything (#4083) [🐴] Additional tweaks to the message list (#4075) Conditionally load unreads (#4072) Revert "Aggregate quickly-sent messages into batches (#4061)" (#4069) 100% Real Deal™ (#4070) [🐴] 60 FPS Keyboard (#4066) Fix delete message error (#4065) Aggregate quickly-sent messages into batches (#4061) [🐴] Input hover and focus styles (#4064) fix typo (#4060) Fix error styles (#4063) Reset leave chat optimistic update if fails (#4058) don't show individual labels on own profile, only "have been placed..." (#4057) [🐴] Tweak header styles (#4053)
* origin/main: [🐴] NUX (#4062) [🐴] Reduce header size (#4078) [🐴] Don't always show notification for everything (#4083) [🐴] Additional tweaks to the message list (#4075) Conditionally load unreads (#4072) Revert "Aggregate quickly-sent messages into batches (#4061)" (#4069) 100% Real Deal™ (#4070) [🐴] 60 FPS Keyboard (#4066) Fix delete message error (#4065) Aggregate quickly-sent messages into batches (#4061) [🐴] Input hover and focus styles (#4064) fix typo (#4060) Fix error styles (#4063) Reset leave chat optimistic update if fails (#4058) don't show individual labels on own profile, only "have been placed..." (#4057) [🐴] Tweak header styles (#4053)
No description provided.