Skip to content

Commit

Permalink
emit Room.redactionCancelled event when undoing redaction local echo
Browse files Browse the repository at this point in the history
  • Loading branch information
bwindels committed Jun 4, 2019
1 parent c0c9f01 commit 58f163e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
13 changes: 12 additions & 1 deletion src/models/room.js
Original file line number Diff line number Diff line change
Expand Up @@ -1323,7 +1323,7 @@ Room.prototype._revertRedactionLocalEcho = function(redactionEvent) {
if (redactedEvent) {
redactedEvent.unmarkLocallyRedacted();
// re-render after undoing redaction
this.emit("Room.redaction", redactionEvent, this);
this.emit("Room.redactionCancelled", redactionEvent, this);
// reapply relation now redaction failed
if (redactedEvent.isRelation()) {
this._aggregateNonLiveRelation(redactedEvent);
Expand Down Expand Up @@ -1838,6 +1838,17 @@ module.exports = Room;
* @param {Room} room The room containing the redacted event
*/

/**
* Fires when an event that was previously redacted isn't anymore.
* This happens when the redaction couldn't be sent and
* was subsequently cancelled by the user. Redactions have a local echo
* which is undone in this scenario.
*
* @event module:client~MatrixClient#"Room.redactionCancelled"
* @param {MatrixEvent} event The matrix event which isn't redacted anymore

This comment has been minimized.

Copy link
@jryans

jryans Jun 4, 2019

Collaborator

I guess we're really emitting the cancelled redaction event, not the event that was redacted, right? This matches what happens for Room.redaction, so it's probably the right thing to emit, so we should just update this comment to match...? (Perhaps the comments for Room.redaction should also be corrected to say the event emitted there is the redaction itself, not the event that was redacted.)

* @param {Room} room The room containing the unredacted event
*/

/**
* Fires whenever the name of a room is updated.
* @event module:client~MatrixClient#"Room.name"
Expand Down
4 changes: 3 additions & 1 deletion src/sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,9 @@ SyncApi.prototype.createRoom = function(roomId) {
timelineSupport,
unstableClientRelationAggregation,
});
client.reEmitter.reEmit(room, ["Room.name", "Room.timeline", "Room.redaction",
client.reEmitter.reEmit(room, ["Room.name", "Room.timeline",
"Room.redaction",
"Room.redactionCancelled",
"Room.receipt", "Room.tags",
"Room.timelineReset",
"Room.localEchoUpdated",
Expand Down

0 comments on commit 58f163e

Please sign in to comment.