diff --git a/spec/unit/models/thread.spec.ts b/spec/unit/models/thread.spec.ts index 480e28f6438..6aa1d5c862e 100644 --- a/spec/unit/models/thread.spec.ts +++ b/spec/unit/models/thread.spec.ts @@ -660,21 +660,14 @@ describe("Thread", () => { }); await thread.addEvent(messageToEdit, false); - // THIS IS THE CORRECT BEHAVIOUR // Then both events end up in the timeline - //const lastEvent = thread.timeline.at(-1)!; - //const secondLastEvent = thread.timeline.at(-2)!; - //expect(lastEvent).toBe(editEvent); - //expect(secondLastEvent).toBe(messageToEdit); - - //// And the first message has been edited - //expect(secondLastEvent.getContent().body).toEqual("edit"); - - // TODO: For now, we incorrecly DON'T add the event to the timeline const lastEvent = thread.timeline.at(-1)!; - expect(lastEvent).toBe(messageToEdit); - // But the original is edited, as expected - expect(lastEvent.getContent().body).toEqual("edit"); + const secondLastEvent = thread.timeline.at(-2)!; + expect(lastEvent).toBe(editEvent); + expect(secondLastEvent).toBe(messageToEdit); + + // And the first message has been edited + expect(secondLastEvent.getContent().body).toEqual("edit"); }); }); }); diff --git a/src/models/thread.ts b/src/models/thread.ts index b04ea63dc34..11727d9704e 100644 --- a/src/models/thread.ts +++ b/src/models/thread.ts @@ -530,8 +530,9 @@ export class Thread extends ReadReceipt { }) .then((relations) => { if (relations.events.length) { - event.makeReplaced(relations.events[0]); - this.insertEventIntoTimeline(event); + const editEvent = relations.events[0]; + event.makeReplaced(editEvent); + this.insertEventIntoTimeline(editEvent); } }) .catch((e) => {