Skip to content

Commit

Permalink
Hide pending events in thread timelines (#2843)
Browse files Browse the repository at this point in the history
  • Loading branch information
Germain authored Nov 8, 2022
1 parent 0fbd0b3 commit bd4589f
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
21 changes: 21 additions & 0 deletions spec/integ/matrix-client-event-timeline.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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() {
Expand Down
5 changes: 4 additions & 1 deletion src/models/room.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1651,7 +1651,10 @@ export class Room extends ReadReceipt<RoomEmittedEvents, RoomEventHandlerMap> {
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,
Expand Down

0 comments on commit bd4589f

Please sign in to comment.