diff --git a/spec/integ/matrix-client-event-timeline.spec.ts b/spec/integ/matrix-client-event-timeline.spec.ts index 4e732184749..fe7393bfd73 100644 --- a/spec/integ/matrix-client-event-timeline.spec.ts +++ b/spec/integ/matrix-client-event-timeline.spec.ts @@ -18,12 +18,14 @@ import * as utils from "../test-utils/test-utils"; import { ClientEvent, Direction, + EventStatus, EventTimeline, EventTimelineSet, Filter, IEvent, MatrixClient, MatrixEvent, + PendingEventOrdering, Room, } from "../../src/matrix"; import { logger } from "../../src/logger"; @@ -1162,6 +1164,25 @@ describe("MatrixClient event timelines", function() { httpBackend.when("GET", "/sync").respond(200, INITIAL_SYNC_DATA); await flushHttp(room.fetchRoomThreads()); }); + + it("should prevent displaying pending events", async function() { + const room = new Room("room123", client, "john", { + pendingEventOrdering: PendingEventOrdering.Detached, + }); + const timelineSets = await room!.createThreadsTimelineSets(); + expect(timelineSets).not.toBeNull(); + + const event = utils.mkMessage({ + room: roomId, user: userId, msg: "a body", event: true, + }); + event.status = EventStatus.SENDING; + room.addPendingEvent(event, "txn"); + + const [allThreads, myThreads] = timelineSets!; + expect(allThreads.getPendingEvents()).toHaveLength(0); + expect(myThreads.getPendingEvents()).toHaveLength(0); + expect(room.getPendingEvents()).toHaveLength(1); + }); }); describe("without server compatibility", function() { diff --git a/src/models/room.ts b/src/models/room.ts index 1055a4c5152..51dd38913ef 100644 --- a/src/models/room.ts +++ b/src/models/room.ts @@ -1651,7 +1651,10 @@ export class Room extends ReadReceipt { let timelineSet: EventTimelineSet; if (Thread.hasServerSideListSupport) { timelineSet = - new EventTimelineSet(this, this.opts, undefined, undefined, filterType ?? ThreadFilterType.All); + new EventTimelineSet(this, { + ...this.opts, + pendingEvents: false, + }, undefined, undefined, filterType ?? ThreadFilterType.All); this.reEmitter.reEmit(timelineSet, [ RoomEvent.Timeline, RoomEvent.TimelineReset,