@@ -24,7 +24,7 @@ import { TimelineWindow } from "matrix-js-sdk/src/timeline-window";
2424import { EventType , RelationType } from 'matrix-js-sdk/src/@types/event' ;
2525import { SyncState } from 'matrix-js-sdk/src/sync' ;
2626import { RoomMember , RoomMemberEvent } from 'matrix-js-sdk/src/models/room-member' ;
27- import { debounce } from 'lodash' ;
27+ import { debounce , throttle } from 'lodash' ;
2828import { logger } from "matrix-js-sdk/src/logger" ;
2929import { ClientEvent } from "matrix-js-sdk/src/client" ;
3030import { Thread } from 'matrix-js-sdk/src/models/thread' ;
@@ -808,23 +808,34 @@ class TimelinePanel extends React.Component<IProps, IState> {
808808 // Can be null for the notification timeline, etc.
809809 if ( ! this . props . timelineSet . room ) return ;
810810
811+ if ( ev . getRoomId ( ) !== this . props . timelineSet . room . roomId ) return ;
812+
813+ if ( ! this . state . events . includes ( ev ) ) return ;
814+
815+ this . recheckFirstVisibleEventIndex ( ) ;
816+
811817 // Need to update as we don't display event tiles for events that
812818 // haven't yet been decrypted. The event will have just been updated
813819 // in place so we just need to re-render.
814820 // TODO: We should restrict this to only events in our timeline,
815821 // but possibly the event tile itself should just update when this
816822 // happens to save us re-rendering the whole timeline.
817- if ( ev . getRoomId ( ) === this . props . timelineSet . room . roomId ) {
818- this . buildCallEventGroupers ( this . state . events ) ;
819- this . forceUpdate ( ) ;
820- }
823+ this . buildCallEventGroupers ( this . state . events ) ;
824+ this . forceUpdate ( ) ;
821825 } ;
822826
823827 private onSync = ( clientSyncState : SyncState , prevState : SyncState , data : object ) : void => {
824828 if ( this . unmounted ) return ;
825829 this . setState ( { clientSyncState } ) ;
826830 } ;
827831
832+ private recheckFirstVisibleEventIndex = throttle ( ( ) : void => {
833+ const firstVisibleEventIndex = this . checkForPreJoinUISI ( this . state . events ) ;
834+ if ( firstVisibleEventIndex !== this . state . firstVisibleEventIndex ) {
835+ this . setState ( { firstVisibleEventIndex } ) ;
836+ }
837+ } , 500 , { leading : true , trailing : true } ) ;
838+
828839 private readMarkerTimeout ( readMarkerPosition : number ) : number {
829840 return readMarkerPosition === 0 ?
830841 this . context ?. readMarkerInViewThresholdMs ?? this . state . readMarkerInViewThresholdMs :
0 commit comments