@@ -407,6 +407,11 @@ const MessageListWithContext = <
407407 return ;
408408 }
409409
410+ if ( selectedPicker === 'images' ) {
411+ setIsUnreadNotificationOpen ( false ) ;
412+ return ;
413+ }
414+
410415 const lastItem = viewableItems [ viewableItems . length - 1 ] ;
411416
412417 if ( lastItem ) {
@@ -578,6 +583,41 @@ const MessageListWithContext = <
578583 // eslint-disable-next-line react-hooks/exhaustive-deps
579584 } , [ rawMessageList , threadList ] ) ;
580585
586+ /**
587+ * Check if a messageId needs to be scrolled to after list loads, and scroll to it
588+ * Note: This effect fires on every list change with a small debounce so that scrolling isnt abrupted by an immediate rerender
589+ */
590+ useEffect ( ( ) => {
591+ scrollToDebounceTimeoutRef . current = setTimeout ( async ( ) => {
592+ const messageIdToScroll : string | undefined = targetedMessage ;
593+ if ( ! messageIdToScroll ) return ;
594+ const indexOfParentInMessageList = processedMessageList . findIndex (
595+ ( message ) => message ?. id === messageIdToScroll ,
596+ ) ;
597+
598+ // the message we want to scroll to has not been loaded in the state yet
599+ if ( indexOfParentInMessageList === - 1 ) {
600+ await loadChannelAroundMessage ( { messageId : messageIdToScroll , setTargetedMessage } ) ;
601+ } else {
602+ if ( ! flatListRef . current ) return ;
603+ // By a fresh scroll we should clear the retries for the previous failed scroll
604+ clearTimeout ( scrollToDebounceTimeoutRef . current ) ;
605+ clearTimeout ( failScrollTimeoutId . current ) ;
606+ // reset the retry count
607+ scrollToIndexFailedRetryCountRef . current = 0 ;
608+ // now scroll to it
609+ flatListRef . current . scrollToIndex ( {
610+ animated : false ,
611+ index : indexOfParentInMessageList ,
612+ viewPosition : 0.5 , // try to place message in the center of the screen
613+ } ) ;
614+ setTargetedMessage ( undefined ) ;
615+ }
616+ } , WAIT_FOR_SCROLL_TO_OFFSET_TIMEOUT ) ;
617+
618+ // eslint-disable-next-line react-hooks/exhaustive-deps
619+ } , [ targetedMessage ] ) ;
620+
581621 // TODO: do not apply on RN 0.73 and above
582622 const shouldApplyAndroidWorkaround = inverted && Platform . OS === 'android' ;
583623
@@ -883,41 +923,6 @@ const MessageListWithContext = <
883923 await loadChannelAroundMessage ( { messageId } ) ;
884924 } ;
885925
886- /**
887- * Check if a messageId needs to be scrolled to after list loads, and scroll to it
888- * Note: This effect fires on every list change with a small debounce so that scrolling isnt abrupted by an immediate rerender
889- */
890- useEffect ( ( ) => {
891- scrollToDebounceTimeoutRef . current = setTimeout ( async ( ) => {
892- const messageIdToScroll : string | undefined = targetedMessage ;
893- if ( ! messageIdToScroll ) return ;
894- const indexOfParentInMessageList = processedMessageList . findIndex (
895- ( message ) => message ?. id === messageIdToScroll ,
896- ) ;
897-
898- // the message we want to scroll to has not been loaded in the state yet
899- if ( indexOfParentInMessageList === - 1 ) {
900- await loadChannelAroundMessage ( { messageId : messageIdToScroll , setTargetedMessage } ) ;
901- } else {
902- if ( ! flatListRef . current ) return ;
903- // By a fresh scroll we should clear the retries for the previous failed scroll
904- clearTimeout ( scrollToDebounceTimeoutRef . current ) ;
905- clearTimeout ( failScrollTimeoutId . current ) ;
906- // reset the retry count
907- scrollToIndexFailedRetryCountRef . current = 0 ;
908- // now scroll to it
909- flatListRef . current . scrollToIndex ( {
910- animated : false ,
911- index : indexOfParentInMessageList ,
912- viewPosition : 0.5 , // try to place message in the center of the screen
913- } ) ;
914- setTargetedMessage ( undefined ) ;
915- }
916- } , WAIT_FOR_SCROLL_TO_OFFSET_TIMEOUT ) ;
917-
918- // eslint-disable-next-line react-hooks/exhaustive-deps
919- } , [ targetedMessage ] ) ;
920-
921926 const messagesWithImages =
922927 legacyImageViewerSwipeBehaviour &&
923928 processedMessageList . filter ( ( message ) => {
0 commit comments