@@ -195,6 +195,15 @@ type MessageFlashListPropsWithContext = Pick<
195195 * ```
196196 */
197197 setFlatListRef ?: ( ref : FlashListRef < LocalMessage > | null ) => void ;
198+ /**
199+ * If true, the message list will be used in a live-streaming scenario.
200+ * This flag is used to make sure that the auto scroll behaves well, if multiple messages are received.
201+ *
202+ * This flag is experimental and is subject to change. Please test thoroughly before using it.
203+ *
204+ * @experimental
205+ */
206+ isLiveStreaming ?: boolean ;
198207 } ;
199208
200209const WAIT_FOR_SCROLL_TIMEOUT = 0 ;
@@ -257,6 +266,7 @@ const MessageFlashListWithContext = (props: MessageFlashListPropsWithContext) =>
257266 InlineDateSeparator,
258267 InlineUnreadIndicator,
259268 isListActive = false ,
269+ isLiveStreaming = false ,
260270 legacyImageViewerSwipeBehaviour,
261271 loadChannelAroundMessage,
262272 loading,
@@ -334,6 +344,7 @@ const MessageFlashListWithContext = (props: MessageFlashListPropsWithContext) =>
334344 const { dateSeparatorsRef, messageGroupStylesRef, processedMessageList, rawMessageList } =
335345 useMessageList ( {
336346 isFlashList : true ,
347+ isLiveStreaming,
337348 noGroupByUser,
338349 threadList,
339350 } ) ;
@@ -363,10 +374,14 @@ const MessageFlashListWithContext = (props: MessageFlashListPropsWithContext) =>
363374 const maintainVisibleContentPosition = useMemo ( ( ) => {
364375 return {
365376 animateAutoscrollToBottom : true ,
366- autoscrollToBottomThreshold : autoScrollToRecent || threadList ? 10 : undefined ,
377+ autoscrollToBottomThreshold : isLiveStreaming
378+ ? 64
379+ : autoScrollToRecent || threadList
380+ ? 10
381+ : undefined ,
367382 startRenderingFromBottom : true ,
368383 } ;
369- } , [ autoScrollToRecent , threadList ] ) ;
384+ } , [ autoScrollToRecent , threadList , isLiveStreaming ] ) ;
370385
371386 useEffect ( ( ) => {
372387 if ( disabled ) {
@@ -1144,6 +1159,7 @@ const MessageFlashListWithContext = (props: MessageFlashListPropsWithContext) =>
11441159 onViewableItemsChanged = { stableOnViewableItemsChanged }
11451160 ref = { refCallback }
11461161 renderItem = { renderItem }
1162+ scrollEventThrottle = { isLiveStreaming ? 16 : undefined }
11471163 showsVerticalScrollIndicator = { false }
11481164 style = { flatListStyle }
11491165 testID = 'message-flash-list'
0 commit comments