-
-
Notifications
You must be signed in to change notification settings - Fork 589
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Local echo for m.replace relations #920
Conversation
now that event can be replaced from Relations instead of Room Also make `makeReplaced` non-destructive by not touching the original event.content, so it can be undone by later calls.
src/models/event.js
Outdated
return this._clearEvent.content || this.event.content || {}; | ||
if (this._replacingEvent && !this.isRedacted()) { | ||
return this._replacingEvent.getContent()["m.new_content"] || {}; | ||
// content = Object.assign({}, content, newContent); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm assuming this gets removed later...
src/models/event.js
Outdated
@@ -226,7 +226,12 @@ utils.extend(module.exports.MatrixEvent.prototype, { | |||
* @return {Object} The event content JSON, or an empty object. | |||
*/ | |||
getContent: function() { | |||
return this._clearEvent.content || this.event.content || {}; | |||
if (this._replacingEvent && !this.isRedacted()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why the redacted check here...?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because we don't want to return any replaced content for a redacted event. I guess a better way to do this would be to set this._replacingEvent
to null
in makeRedacted
.
src/models/event-timeline-set.js
Outdated
@@ -759,7 +759,7 @@ EventTimelineSet.prototype.aggregateRelations = function(event) { | |||
} | |||
} | |||
|
|||
relationsWithEventType.addEvent(event); | |||
relationsWithEventType.addEvent(event, relatesToEvent); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should add a separate setTargetEvent
or similar to do this separately, and also ensure we only do it one time per relations collection (once the target event is found), as findEventById
is not very efficient.
call makeReplaced from addEvent instead so it's all done from Relations
as redaction supersedes a replacement
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, this looks good to me! 😁
Part of: element-hq/element-web#9671
React-SDK PR: matrix-org/matrix-react-sdk#2982