Skip to content

Commit 36f28a8

Browse files
committed
fix: livestreaming mode MVCP
1 parent db6bceb commit 36f28a8

File tree

2 files changed

+3
-37
lines changed

2 files changed

+3
-37
lines changed

package/src/components/MessageList/MessageFlashList.tsx

Lines changed: 2 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,6 @@ const MessageFlashListWithContext = (props: MessageFlashListPropsWithContext) =>
313313
const [scrollToBottomButtonVisible, setScrollToBottomButtonVisible] = useState(false);
314314
const [isUnreadNotificationOpen, setIsUnreadNotificationOpen] = useState<boolean>(false);
315315
const [stickyHeaderDate, setStickyHeaderDate] = useState<Date | undefined>();
316-
const [autoScrollToRecent, setAutoScrollToRecent] = useState(false);
317316

318317
const stickyHeaderDateRef = useRef<Date | undefined>(undefined);
319318
/**
@@ -380,14 +379,10 @@ const MessageFlashListWithContext = (props: MessageFlashListPropsWithContext) =>
380379
const maintainVisibleContentPosition = useMemo(() => {
381380
return {
382381
animateAutoscrollToBottom: true,
383-
autoscrollToBottomThreshold: isLiveStreaming
384-
? 64
385-
: autoScrollToRecent || threadList
386-
? 10
387-
: undefined,
382+
autoscrollToBottomThreshold: 1,
388383
startRenderingFromBottom: true,
389384
};
390-
}, [autoScrollToRecent, threadList, isLiveStreaming]);
385+
}, []);
391386

392387
useEffect(() => {
393388
if (disabled) {
@@ -486,13 +481,11 @@ const MessageFlashListWithContext = (props: MessageFlashListPropsWithContext) =>
486481
setScrollToBottomButtonVisible(false);
487482
resetPaginationTrackersRef.current();
488483

489-
setAutoScrollToRecent(true);
490484
setTimeout(() => {
491485
channelResyncScrollSet.current = true;
492486
if (channel.countUnread() > 0) {
493487
markRead();
494488
}
495-
setAutoScrollToRecent(false);
496489
}, WAIT_FOR_SCROLL_TIMEOUT);
497490
}
498491
};
@@ -515,7 +508,6 @@ const MessageFlashListWithContext = (props: MessageFlashListPropsWithContext) =>
515508
if (notLatestSet) {
516509
latestNonCurrentMessageBeforeUpdateRef.current =
517510
channel.state.latestMessages[channel.state.latestMessages.length - 1];
518-
setAutoScrollToRecent(false);
519511
setScrollToBottomButtonVisible(true);
520512
return;
521513
}
@@ -524,7 +516,6 @@ const MessageFlashListWithContext = (props: MessageFlashListPropsWithContext) =>
524516

525517
const latestCurrentMessageAfterUpdate = processedMessageList[processedMessageList.length - 1];
526518
if (!latestCurrentMessageAfterUpdate) {
527-
setAutoScrollToRecent(true);
528519
return;
529520
}
530521
const didMergeMessageSetsWithNoUpdates =
@@ -542,28 +533,6 @@ const MessageFlashListWithContext = (props: MessageFlashListPropsWithContext) =>
542533
}
543534
}, [channel, processedMessageList, shouldScrollToRecentOnNewOwnMessageRef, threadList]);
544535

545-
/**
546-
* Effect to scroll to the bottom of the message list when a new message is received if the scroll to bottom button is not visible.
547-
*/
548-
useEffect(() => {
549-
const handleEvent = (event: Event) => {
550-
if (event.message?.user?.id !== client.userID) {
551-
if (!scrollToBottomButtonVisible) {
552-
flashListRef.current?.scrollToEnd({
553-
animated: true,
554-
});
555-
} else {
556-
setAutoScrollToRecent(false);
557-
}
558-
}
559-
};
560-
const listener: ReturnType<typeof channel.on> = channel.on('message.new', handleEvent);
561-
562-
return () => {
563-
listener?.unsubscribe();
564-
};
565-
}, [channel, client.userID, scrollToBottomButtonVisible]);
566-
567536
/**
568537
* Effect to mark the channel as read when the user scrolls to the bottom of the message list.
569538
*/

package/src/components/MessageList/MessageList.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -348,10 +348,7 @@ const MessageListWithContext = (props: MessageListPropsWithContext) => {
348348

349349
const minIndexForVisible = Math.min(1, processedMessageList.length);
350350

351-
const autoscrollToTopThreshold = useMemo(
352-
() => (isLiveStreaming ? 64 : autoscrollToRecent ? 10 : undefined),
353-
[autoscrollToRecent, isLiveStreaming],
354-
);
351+
const autoscrollToTopThreshold = autoscrollToRecent ? (isLiveStreaming ? 64 : 10) : undefined;
355352

356353
const maintainVisibleContentPosition = useMemo(
357354
() => ({

0 commit comments

Comments
 (0)