diff --git a/spec/unit/event-timeline-set.spec.ts b/spec/unit/event-timeline-set.spec.ts index 61b30edb36..352e882130 100644 --- a/spec/unit/event-timeline-set.spec.ts +++ b/spec/unit/event-timeline-set.spec.ts @@ -23,6 +23,7 @@ import { EventTimelineSet, EventType, Filter, + KnownMembership, MatrixClient, MatrixEvent, MatrixEventEvent, @@ -138,6 +139,31 @@ describe("EventTimelineSet", () => { expect(eventsInLiveTimeline.length).toStrictEqual(1); expect(eventsInLiveTimeline[0]).toStrictEqual(duplicateMessageEvent); }); + + it("should set event.target after applying the membership state update", () => { + const eventTimelineSet = room.getUnfilteredTimelineSet(); + + const ev1 = utils.mkMembership({ + room: roomId, + mship: KnownMembership.Invite, + user: "@sender:server", + skey: userA, + event: true, + }); + const ev2 = utils.mkMembership({ + room: roomId, + mship: KnownMembership.Join, + user: userA, + skey: userA, + name: "This is my displayname", + event: true, + }); + + eventTimelineSet.addLiveEvent(ev1, { addToState: true }); + expect(ev1.target?.name).toBe(userA); + eventTimelineSet.addLiveEvent(ev2, { addToState: true }); + expect(ev2.target?.name).toBe("This is my displayname"); + }); }); describe("addEventToTimeline", () => { diff --git a/src/client.ts b/src/client.ts index eea8faa708..0e49b16091 100644 --- a/src/client.ts +++ b/src/client.ts @@ -7348,10 +7348,8 @@ export class MatrixClient extends TypedEventEmitter void; [MatrixEventEvent.Replaced]: (event: MatrixEvent) => void; [MatrixEventEvent.RelationsCreated]: (relationType: string, eventType: string) => void; + [MatrixEventEvent.SentinelUpdated]: () => void; } & Pick; export class MatrixEvent extends TypedEventEmitter { @@ -328,6 +331,7 @@ export class MatrixEvent extends TypedEventEmitter