mirror of
https://github.com/zulip/zulip.git
synced 2025-11-07 07:23:22 +00:00
The message_hover function in ui_init.js had an if condition to return early when is_topic_editable was false. We instead change it to return early when message.sent_by_me is false since in that case the edit_content element is not present. Note that we also show the "View source" icon when message is locally echoed or not sent successfully. Till now is_topic_editable is always true when message is sent by the user itself, and when message is sent by someone else the edit_content element does not exist in the DOM anyway. So, basically, it just helps in returing early and not unnecessarily move forward to set html for a non-existent div. So, we can ideally replace it with just `sent_by_me` condition and otherwise we already show the reaction icon. The comment above that also mentioned that "locally echoed messages have !is_topic_editable" which is not true since is_topic_editable does not check whether the message is locally-echoed or not. This comment was added ine1c4c7b80. This also fixes the bug where "View source" icon is not shown when "message.sent_by_me" is true and both editing and moving message is not allowed which currently happens when allow_message_editing setting is False. Also, the "is_topic_editable" condition will be not valid in future when "is_topic_editable" can be false when "sent_by_me" is true. In such cases we would not show any icon then, so better to fix this here. Some history of this code- - Intially we returned only when !sent_by_me was false, but added a condition to return early when realm_allow_community_topic_editing was false in91197fa4f1. Though it was not needed since edit_content element amyways did not existed when `sent_by_me` was false. - Then the condition was then changed to return early if is_topic_editable was false in689c717284.
27 KiB
27 KiB