@@ -200,6 +200,15 @@ type MessageFlashListPropsWithContext = Pick<
200200 * ```
201201 */
202202 setFlatListRef ?: ( ref : FlashListRef < LocalMessage > | null ) => void ;
203+ /**
204+ * If true, the message list will be used in a live-streaming scenario.
205+ * This flag is used to make sure that the auto scroll behaves well, if multiple messages are received.
206+ *
207+ * This flag is experimental and is subject to change. Please test thoroughly before using it.
208+ *
209+ * @experimental
210+ */
211+ isLiveStreaming ?: boolean ;
203212 } ;
204213
205214const WAIT_FOR_SCROLL_TIMEOUT = 0 ;
@@ -262,6 +271,7 @@ const MessageFlashListWithContext = (props: MessageFlashListPropsWithContext) =>
262271 InlineDateSeparator,
263272 InlineUnreadIndicator,
264273 isListActive = false ,
274+ isLiveStreaming = false ,
265275 legacyImageViewerSwipeBehaviour,
266276 loadChannelAroundMessage,
267277 loading,
@@ -340,6 +350,7 @@ const MessageFlashListWithContext = (props: MessageFlashListPropsWithContext) =>
340350 const { dateSeparatorsRef, messageGroupStylesRef, processedMessageList, rawMessageList } =
341351 useMessageList ( {
342352 isFlashList : true ,
353+ isLiveStreaming,
343354 noGroupByUser,
344355 threadList,
345356 } ) ;
@@ -369,10 +380,14 @@ const MessageFlashListWithContext = (props: MessageFlashListPropsWithContext) =>
369380 const maintainVisibleContentPosition = useMemo ( ( ) => {
370381 return {
371382 animateAutoscrollToBottom : true ,
372- autoscrollToBottomThreshold : autoScrollToRecent || threadList ? 10 : undefined ,
383+ autoscrollToBottomThreshold : isLiveStreaming
384+ ? 64
385+ : autoScrollToRecent || threadList
386+ ? 10
387+ : undefined ,
373388 startRenderingFromBottom : true ,
374389 } ;
375- } , [ autoScrollToRecent , threadList ] ) ;
390+ } , [ autoScrollToRecent , threadList , isLiveStreaming ] ) ;
376391
377392 useEffect ( ( ) => {
378393 if ( disabled ) {
@@ -1150,6 +1165,7 @@ const MessageFlashListWithContext = (props: MessageFlashListPropsWithContext) =>
11501165 onViewableItemsChanged = { stableOnViewableItemsChanged }
11511166 ref = { refCallback }
11521167 renderItem = { renderItem }
1168+ scrollEventThrottle = { isLiveStreaming ? 16 : undefined }
11531169 showsVerticalScrollIndicator = { false }
11541170 style = { flatListStyle }
11551171 testID = 'message-flash-list'
0 commit comments