-
-
Notifications
You must be signed in to change notification settings - Fork 7.5k
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
message_edit: Fix local echo of message edit. #29338
Conversation
bfe3793
to
a171007
Compare
web/src/message_list_view.js
Outdated
message_containers = messages.map((message) => { | ||
const message_container = this.message_containers.get(message.id); | ||
message_container.msg.content = message.content; | ||
return message_container; |
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 think we need to be careful with mutating the core message object here; this may persist more than we'd expect. I'm not sure what the right strategy is, but I think it's pretty likely that if the edit operation fails, this doesn't get undone.
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 think it won't be much of a problem. If the patch
request for save_message_row_edit
fails, we can see that the original content is being restored, and the message_container is being re-rendered here, with original content and message_content_edited
being set to false.
Manually testing by stopping the server and editing, it didn't seem like a problem either.
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 sure this isn't the right fix for this. I guess I'll give it another try to fix it.
@timabbott Marking for integration review since you seem to be looking at this one, and there's a response to your comment above. |
97ded2b
to
6801aad
Compare
Previously, when a message is edited, it is locally echoed with its pre-edit content. This is because previously, when we tried to render the edited message of the edit box during local echo, in order to update the content, flags, and is_me_message properties of the message object with that of those returned is markdown.render(), we used the spread operator and created a new message object, and updated the existing message object with this new one. This was misconverted, since edit_locally() method already has a fully-rendered message object to start with, and is just doing a rerendering, it should be mutating what message it received, rather than constructing a new local variable.
6801aad
to
b24cadf
Compare
@timabbott this bug still persists. approach is described here |
Great, merged, thanks @roanster007! Probably copying the most important part of the chat.zulip.org thread would have helped me review this more quickly; it took me a while to understand. |
Previously, when a message is edited, it is locally echoed with its
pre-edit content.
This is because previously, when we tried to render the edited
message of the edit box during local echo, in order to update
the content, flags, and is_me_message properties of the message
object with that of those returned is markdown.render(), we used
the spread operator and created a new message object, and updated
the existing message object with this new one.
This was misconverted, since edit_locally() method already has a
fully-rendered message object to start with, and is just doing a
rerendering, it should be mutating what message it received, rather
than constructing a new local variable.
CZO
Screenshots and screen captures:
Self-review checklist
(variable names, code reuse, readability, etc.).
Communicate decisions, questions, and potential concerns.
Individual commits are ready for review (see commit discipline).
Completed manual review and testing of the following: