Skip to content

Commit

Permalink
fix: scroll to message after channel state is copied reliably
Browse files Browse the repository at this point in the history
  • Loading branch information
santhoshvai committed Mar 4, 2024
1 parent 068d722 commit 93f521b
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions package/src/components/Channel/Channel.tsx
Expand Up @@ -753,7 +753,7 @@ const ChannelWithContext = <

const copyChannelState = useRef(
throttle(
() => {
(onComplete: (() => void) | undefined = undefined) => {
setLoading(false);
if (channel) {
setMembers({ ...channel.state.members });
Expand All @@ -762,6 +762,7 @@ const ChannelWithContext = <
setTyping({ ...channel.state.typing });
setWatcherCount(channel.state.watcher_count);
setWatchers({ ...channel.state.watchers });
onComplete?.();
}
},
stateUpdateThrottleInterval,
Expand Down Expand Up @@ -891,9 +892,11 @@ const ChannelWithContext = <
const hasLatestMessages = channel.state.latestMessages.length > 0;
channel.state.setIsUpToDate(hasLatestMessages);
setHasNoMoreRecentMessagesToLoad(hasLatestMessages);
copyChannelState();
restartSetsMergeFuncRef.current();
onAfterQueryCall?.();
copyChannelState(() => {
// only after the debounce interval completes, we will merge the sets and set any other states
restartSetsMergeFuncRef.current();
onAfterQueryCall?.();
});
} catch (err) {
if (err instanceof Error) {
setError(err);
Expand Down

0 comments on commit 93f521b

Please sign in to comment.