@@ -24,7 +24,7 @@ import { TimelineWindow } from "matrix-js-sdk/src/timeline-window";
24
24
import { EventType , RelationType } from 'matrix-js-sdk/src/@types/event' ;
25
25
import { SyncState } from 'matrix-js-sdk/src/sync' ;
26
26
import { RoomMember , RoomMemberEvent } from 'matrix-js-sdk/src/models/room-member' ;
27
- import { debounce } from 'lodash' ;
27
+ import { debounce , throttle } from 'lodash' ;
28
28
import { logger } from "matrix-js-sdk/src/logger" ;
29
29
import { ClientEvent } from "matrix-js-sdk/src/client" ;
30
30
import { Thread } from 'matrix-js-sdk/src/models/thread' ;
@@ -808,23 +808,34 @@ class TimelinePanel extends React.Component<IProps, IState> {
808
808
// Can be null for the notification timeline, etc.
809
809
if ( ! this . props . timelineSet . room ) return ;
810
810
811
+ if ( ev . getRoomId ( ) !== this . props . timelineSet . room . roomId ) return ;
812
+
813
+ if ( ! this . state . events . includes ( ev ) ) return ;
814
+
815
+ this . recheckFirstVisibleEventIndex ( ) ;
816
+
811
817
// Need to update as we don't display event tiles for events that
812
818
// haven't yet been decrypted. The event will have just been updated
813
819
// in place so we just need to re-render.
814
820
// TODO: We should restrict this to only events in our timeline,
815
821
// but possibly the event tile itself should just update when this
816
822
// 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 ( ) ;
821
825
} ;
822
826
823
827
private onSync = ( clientSyncState : SyncState , prevState : SyncState , data : object ) : void => {
824
828
if ( this . unmounted ) return ;
825
829
this . setState ( { clientSyncState } ) ;
826
830
} ;
827
831
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
+
828
839
private readMarkerTimeout ( readMarkerPosition : number ) : number {
829
840
return readMarkerPosition === 0 ?
830
841
this . context ?. readMarkerInViewThresholdMs ?? this . state . readMarkerInViewThresholdMs :
0 commit comments