-
Notifications
You must be signed in to change notification settings - Fork 134
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
refactor: stable scroll behavior #1094
Conversation
✅ Deploy Preview for sendbird-uikit-react ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
b827933
to
648fa7a
Compare
} | ||
}, | ||
}); | ||
|
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.
Moved to <InfiniteList />
scrollDistanceFromBottomRef.current = distanceFromBottom; | ||
}, | ||
}); | ||
|
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.
Moved to <InfiniteList />
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.
LGTM
@@ -42,7 +46,11 @@ const pubSubFactory = < | |||
publish: (topic, info) => { | |||
if (topics[topic]) { | |||
topics[topic].forEach((fn) => { | |||
setTimeout(() => fn(info !== undefined ? info : {}), 0); | |||
if (opts?.publishSynchronous) { |
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's the purpose of synchronous?
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.
When publishing events, you can choose between synchronous and asynchronous execution.
Here are the differences illustrated with examples:
Synchronous Execution:
fns.forEach(fn => fn());
- Blocking: Each function runs to completion before the next one starts, potentially causing delays if any function takes time.
- Predictable Order: Functions execute in the exact order they are called.
Asynchronous Execution:
fns.forEach(fn => setTimeout(() => fn(), 0));
- Non-blocking: Functions are scheduled to run after the current execution context, keeping the main thread free.
- Less Predictable Order: Functions might not execute in the strict order they are scheduled due to other asynchronous tasks.
src/modules/GroupChannel/components/MessageList/InfiniteList.tsx
Outdated
Show resolved
Hide resolved
0d9127c
to
bf1997b
Compare
Changes
test link
before: https://sendbird-uikit-react.netlify.app/
after: https://deploy-preview-1094--sendbird-uikit-react.netlify.app/
ticket: CLNP-3273