You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-12-05 17:02:07 +03:00
make replacements work in e2e rooms
This commit is contained in:
@@ -758,6 +758,10 @@ utils.extend(module.exports.MatrixEvent.prototype, {
|
|||||||
if (this.isRedacted()) {
|
if (this.isRedacted()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (newEvent.isBeingDecrypted()) {
|
||||||
|
throw new Error("Trying to replace event when " +
|
||||||
|
"new content hasn't been decrypted yet");
|
||||||
|
}
|
||||||
const oldContent = this.getContent();
|
const oldContent = this.getContent();
|
||||||
const newContent = newEvent.getContent()["m.new_content"];
|
const newContent = newEvent.getContent()["m.new_content"];
|
||||||
// need to always replace m.relates_to with the old one,
|
// need to always replace m.relates_to with the old one,
|
||||||
|
|||||||
@@ -1038,8 +1038,16 @@ Room.prototype._addLiveEvent = function(event, duplicateStrategy) {
|
|||||||
const replacedId = relatesTo && relatesTo.event_id;
|
const replacedId = relatesTo && relatesTo.event_id;
|
||||||
const replacedEvent = this.getUnfilteredTimelineSet().findEventById(replacedId);
|
const replacedEvent = this.getUnfilteredTimelineSet().findEventById(replacedId);
|
||||||
if (replacedEvent) {
|
if (replacedEvent) {
|
||||||
|
const doAndEmitReplacement = () => {
|
||||||
replacedEvent.makeReplaced(event);
|
replacedEvent.makeReplaced(event);
|
||||||
this.emit("Room.replaceEvent", replacedEvent, this);
|
this.emit("Room.replaceEvent", replacedEvent, this);
|
||||||
|
};
|
||||||
|
|
||||||
|
if (event.isBeingDecrypted()) {
|
||||||
|
event.once("Event.decrypted", doAndEmitReplacement);
|
||||||
|
} else {
|
||||||
|
doAndEmitReplacement();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user