From 2eecea9a07a05fac94d96a3218a3c5bc0a1f82c7 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Mon, 3 Jun 2019 18:37:01 +0200 Subject: [PATCH] handle redactions in room pending event logic --- src/models/room.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/models/room.js b/src/models/room.js index ec3ffb764..2c3376548 100644 --- a/src/models/room.js +++ b/src/models/room.js @@ -1124,6 +1124,15 @@ Room.prototype.addPendingEvent = function(event, txnId) { } } } + + if (event.getType() === "m.room.redaction") { + const redactId = event.event.redacts; + const redactedEvent = this.getUnfilteredTimelineSet().findEventById(redactId); + if (redactedEvent) { + redactedEvent.markLocallyRedacted(event); + this.emit("Room.redaction", event, this); + } + } } else { for (let i = 0; i < this._timelineSets.length; i++) { const timelineSet = this._timelineSets[i]; @@ -1368,6 +1377,17 @@ Room.prototype.removeEvent = function(eventId) { for (let i = 0; i < this._timelineSets.length; i++) { const removed = this._timelineSets[i].removeEvent(eventId); if (removed) { + // undo local echo of redaction + if (removed.getType() === "m.room.redaction") { + const redactId = event.event.redacts; + const redactedEvent = this.getUnfilteredTimelineSet() + .findEventById(redactId); + if (redactedEvent) { + redactedEvent.unmarkLocallyRedacted(); + // re-render after undoing redaction + this.emit("Room.redaction", removed, this); + } + } removedAny = true; } }