You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-11-29 16:43:09 +03:00
handle m.replace relations in room, emit Room.replaceEvent
This commit is contained in:
@@ -1028,6 +1028,27 @@ Room.prototype._addLiveEvent = function(event, duplicateStrategy) {
|
|||||||
// this may be needed to trigger an update.
|
// this may be needed to trigger an update.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (event.isReplacement()) {
|
||||||
|
const replacedEventId = event.getOriginalId();
|
||||||
|
const replacedEvent = replacedEventId &&
|
||||||
|
this.getUnfilteredTimelineSet().tryReplaceEvent(replacedEventId, event);
|
||||||
|
if (replacedEvent) {
|
||||||
|
// if this was already a replacement, get the original
|
||||||
|
let originalEvent = replacedEvent;
|
||||||
|
if (originalEvent.isReplacement()) {
|
||||||
|
originalEvent = originalEvent.getReplacedEvent();
|
||||||
|
}
|
||||||
|
event.setReplacedEvent(originalEvent);
|
||||||
|
// report replacedEvent and not originalEvent because replaceEvent was in the timeline so far
|
||||||
|
this.emit("Room.replaceEvent", replacedEvent, event, this);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
console.warn(`could not find replaced event for target id ${replacedEventId} and if ${event.getId()}, body: ${event.getContent().body}`);
|
||||||
|
}
|
||||||
|
// we don't add the event because the event type would get rendered
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (event.getUnsigned().transaction_id) {
|
if (event.getUnsigned().transaction_id) {
|
||||||
const existingEvent = this._txnToEvent[event.getUnsigned().transaction_id];
|
const existingEvent = this._txnToEvent[event.getUnsigned().transaction_id];
|
||||||
if (existingEvent) {
|
if (existingEvent) {
|
||||||
|
|||||||
@@ -132,6 +132,7 @@ SyncApi.prototype.createRoom = function(roomId) {
|
|||||||
"Room.localEchoUpdated",
|
"Room.localEchoUpdated",
|
||||||
"Room.accountData",
|
"Room.accountData",
|
||||||
"Room.myMembership",
|
"Room.myMembership",
|
||||||
|
"Room.replaceEvent",
|
||||||
]);
|
]);
|
||||||
this._registerStateListeners(room);
|
this._registerStateListeners(room);
|
||||||
return room;
|
return room;
|
||||||
|
|||||||
Reference in New Issue
Block a user