@@ -335,12 +335,14 @@ const MessageListWithContext = (props: MessageListPropsWithContext) => {
335335
336336 const [ autoscrollToRecent , setAutoscrollToRecent ] = useState ( false ) ;
337337
338+ const minIndexForVisible = Math . min ( 1 , processedMessageList . length ) ;
339+
338340 const maintainVisibleContentPosition = useMemo (
339341 ( ) => ( {
340342 autoscrollToTopThreshold : autoscrollToRecent ? 10 : undefined ,
341- minIndexForVisible : 1 ,
343+ minIndexForVisible,
342344 } ) ,
343- [ autoscrollToRecent ] ,
345+ [ autoscrollToRecent , minIndexForVisible ] ,
344346 ) ;
345347
346348 /**
@@ -620,7 +622,7 @@ const MessageListWithContext = (props: MessageListPropsWithContext) => {
620622 } , [ threadList , messageListLengthAfterUpdate , topMessageAfterUpdate ?. id ] ) ;
621623
622624 useEffect ( ( ) => {
623- if ( ! rawMessageList . length ) {
625+ if ( ! processedMessageList . length ) {
624626 return ;
625627 }
626628 if ( threadList ) {
@@ -637,7 +639,7 @@ const MessageListWithContext = (props: MessageListPropsWithContext) => {
637639 }
638640 const latestNonCurrentMessageBeforeUpdate = latestNonCurrentMessageBeforeUpdateRef . current ;
639641 latestNonCurrentMessageBeforeUpdateRef . current = undefined ;
640- const latestCurrentMessageAfterUpdate = rawMessageList [ rawMessageList . length - 1 ] ;
642+ const latestCurrentMessageAfterUpdate = processedMessageList [ 0 ] ;
641643 if ( ! latestCurrentMessageAfterUpdate ) {
642644 setAutoscrollToRecent ( true ) ;
643645 return ;
@@ -662,7 +664,7 @@ const MessageListWithContext = (props: MessageListPropsWithContext) => {
662664 }
663665 }
664666 // eslint-disable-next-line react-hooks/exhaustive-deps
665- } , [ channel , rawMessageList , threadList ] ) ;
667+ } , [ channel , processedMessageList , threadList ] ) ;
666668
667669 const goToMessage = useStableCallback ( async ( messageId : string ) => {
668670 const indexOfParentInMessageList = processedMessageList . findIndex (
0 commit comments