@@ -197,7 +197,7 @@ type MessageFlashListPropsWithContext = Pick<
197197 setFlatListRef ?: ( ref : FlashListRef < LocalMessage > | null ) => void ;
198198 } ;
199199
200- const WAIT_FOR_SCROLL_TIMEOUT = 200 ;
200+ const WAIT_FOR_SCROLL_TIMEOUT = 0 ;
201201
202202const getItemTypeInternal = ( message : LocalMessage ) => {
203203 if ( message . type === 'regular' ) {
@@ -433,17 +433,17 @@ const MessageFlashListWithContext = (props: MessageFlashListPropsWithContext) =>
433433 }
434434 try {
435435 if ( indexOfParentInMessageList === - 1 ) {
436+ clearTimeout ( scrollToDebounceTimeoutRef . current ) ;
436437 await loadChannelAroundMessage ( { messageId } ) ;
437438 setTargetedMessage ( messageId ) ;
438439
439- setTimeout ( ( ) => {
440- // now scroll to it with animated=true
441- flashListRef . current ?. scrollToIndex ( {
442- animated : true ,
443- index : indexOfParentInMessageList ,
444- viewPosition : 0.5 , // try to place message in the center of the screen
445- } ) ;
446- } , WAIT_FOR_SCROLL_TIMEOUT ) ;
440+ // now scroll to it with animated=true
441+ flashListRef . current ?. scrollToIndex ( {
442+ animated : true ,
443+ index : indexOfParentInMessageList ,
444+ viewPosition : 0.5 , // try to place message in the center of the screen
445+ } ) ;
446+ return ;
447447 }
448448 } catch ( e ) {
449449 console . warn ( 'Error while scrolling to message' , e ) ;
@@ -468,16 +468,12 @@ const MessageFlashListWithContext = (props: MessageFlashListPropsWithContext) =>
468468 return ;
469469 }
470470
471- if (
472- isMessageRemovedFromMessageList ||
473- ( topMessageBeforeUpdate . current ?. created_at &&
474- topMessageAfterUpdate ?. created_at &&
475- topMessageBeforeUpdate . current . created_at < topMessageAfterUpdate . created_at )
476- ) {
471+ if ( isMessageRemovedFromMessageList ) {
477472 channelResyncScrollSet . current = false ;
478473 setScrollToBottomButtonVisible ( false ) ;
479474 resetPaginationTrackersRef . current ( ) ;
480475
476+ console . log ( 'scrollToEnd 1' ) ;
481477 setAutoScrollToRecent ( true ) ;
482478 setTimeout ( ( ) => {
483479 channelResyncScrollSet . current = true ;
@@ -960,7 +956,7 @@ const MessageFlashListWithContext = (props: MessageFlashListPropsWithContext) =>
960956 const offset = nativeEvent . contentOffset . y ;
961957 const visibleLength = nativeEvent . layoutMeasurement . height ;
962958 const contentLength = nativeEvent . contentSize . height ;
963- if ( ! channel ) {
959+ if ( ! channel || ! channelResyncScrollSet . current ) {
964960 return ;
965961 }
966962
0 commit comments