@@ -194,22 +194,10 @@ export class RoomState extends TypedEventEmitter<EmittedEvents, EventHandlerMap>
194194 * As the timeline might get reset while they are loading, this state needs to be inherited
195195 * and shared when the room state is cloned for the new timeline.
196196 * This should only be passed from clone.
197- * @param isStartTimelineState - Optional. This state is marked as a start state.
198- * This is used to skip state insertions that are
199- * in the wrong order. The order is determined by the `replaces_state` id.
200- *
201- * Example:
202- * A current state events `replaces_state` value is `1`.
203- * Trying to insert a state event with `event_id` `1` in its place would fail if isStartTimelineState = false.
204- *
205- * A current state events `event_id` is `2`.
206- * Trying to insert a state event where its `replaces_state` value is `2` would fail if isStartTimelineState = true.
207197 */
208-
209198 public constructor (
210199 public readonly roomId : string ,
211200 private oobMemberFlags = { status : OobStatus . NotStarted } ,
212- public readonly isStartTimelineState = false ,
213201 ) {
214202 super ( ) ;
215203 this . updateModifiedTime ( ) ;
@@ -420,7 +408,7 @@ export class RoomState extends TypedEventEmitter<EmittedEvents, EventHandlerMap>
420408 * Fires {@link RoomStateEvent.Events}
421409 * Fires {@link RoomStateEvent.Marker}
422410 */
423- public setStateEvents ( stateEvents : MatrixEvent [ ] , options ?: IMarkerFoundOptions ) : void {
411+ public setStateEvents ( stateEvents : MatrixEvent [ ] , markerFoundOptions ?: IMarkerFoundOptions ) : void {
424412 this . updateModifiedTime ( ) ;
425413
426414 // update the core event dict
@@ -432,22 +420,6 @@ export class RoomState extends TypedEventEmitter<EmittedEvents, EventHandlerMap>
432420 }
433421
434422 const lastStateEvent = this . getStateEventMatching ( event ) ;
435-
436- // Safety measure to not update the room (and emit the update) with older state.
437- // The sync loop really should not send old events but it does very regularly.
438- // Logging on return in those two conditions results in a large amount of logging. (on startup and when running element)
439- const lastReplaceId = lastStateEvent ?. event . unsigned ?. replaces_state ;
440- const lastId = lastStateEvent ?. event . event_id ;
441- const newReplaceId = event . event . unsigned ?. replaces_state ;
442- const newId = event . event . event_id ;
443- if ( this . isStartTimelineState ) {
444- // Add an event to the start of the timeline. Its replace id should not be the same as the one of the current/last start state event.
445- if ( newReplaceId && lastId && newReplaceId === lastId ) return ;
446- } else {
447- // Add an event to the end of the timeline. It should not be the same as the one replaced by the current/last end state event.
448- if ( lastReplaceId && newId && lastReplaceId === newId ) return ;
449- }
450-
451423 this . setStateEvent ( event ) ;
452424 if ( event . getType ( ) === EventType . RoomMember ) {
453425 this . updateDisplayNameCache ( event . getStateKey ( ) ! , event . getContent ( ) . displayname ?? "" ) ;
@@ -504,7 +476,7 @@ export class RoomState extends TypedEventEmitter<EmittedEvents, EventHandlerMap>
504476 // assume all our sentinels are now out-of-date
505477 this . sentinels = { } ;
506478 } else if ( UNSTABLE_MSC2716_MARKER . matches ( event . getType ( ) ) ) {
507- this . emit ( RoomStateEvent . Marker , event , options ) ;
479+ this . emit ( RoomStateEvent . Marker , event , markerFoundOptions ) ;
508480 }
509481 } ) ;
510482
0 commit comments