message_edit: Apply topic edit restrictions to "(no topic)" messages.

Previously, editing topic of "(no topic)" messages was allowed
irrespective of time limit or the "edit_topic_policy" setting.
Since we are working in the direction of having "no topic" messages
feel reasonable, this commit changes the code to not consider them
as a special case and topic editing restrictions apply to them as
well now like all other messages.

We still highlight the topic edit icon in recipient bar without
hovering for "no topic" messages, but it is only shown when user
has permission to edit topics.
This commit is contained in:
Sahil Batra
2023-03-16 18:02:30 +05:30
committed by Tim Abbott
parent 61fa24fd5e
commit 440f9e397a
7 changed files with 28 additions and 32 deletions

View File

@@ -156,14 +156,21 @@ function set_timestr(message_container) {
function set_topic_edit_properties(group, message) {
group.always_visible_topic_edit = false;
group.on_hover_topic_edit = false;
const is_topic_editable = message_edit.is_topic_editable(message);
// if a user who can edit a topic, can resolve it as well
group.user_can_resolve_topic = message_edit.is_topic_editable(message);
group.user_can_resolve_topic = is_topic_editable;
if (!is_topic_editable) {
return;
}
// Messages with no topics should always have an edit icon visible
// to encourage updating them. Admins can also edit any topic.
if (message.topic === compose.empty_topic_placeholder()) {
group.always_visible_topic_edit = true;
} else if (message_edit.is_topic_editable(message)) {
} else {
group.on_hover_topic_edit = true;
}
}