popovers: Use can_move_message function.

We can now directly use `can_move_message` function instead
of checking topic and stream edit permission. This helps us
in avoid duplication of code.
This commit is contained in:
Sahil Batra 2022-10-13 17:34:14 +05:30 committed by Tim Abbott
parent ad3fe2c0db
commit 2451002e3b
2 changed files with 5 additions and 10 deletions

View File

@ -534,8 +534,8 @@ export function toggle_actions_popover(element, id) {
!message_container.is_hidden &&
not_spectator;
const editability = message_edit.get_editability(message);
const is_stream_editable =
message.is_stream && settings_data.user_can_move_messages_between_streams();
const can_move_message = message_edit.can_move_message(message);
let editability_menu_item;
let move_message_menu_item;
let view_source_menu_item;
@ -545,10 +545,7 @@ export function toggle_actions_popover(element, id) {
if (message.is_stream) {
move_message_menu_item = $t({defaultMessage: "Move message"});
}
} else if (
editability === message_edit.editability_types.TOPIC_ONLY ||
is_stream_editable
) {
} else if (can_move_message) {
move_message_menu_item = $t({defaultMessage: "Move message"});
view_source_menu_item = $t({defaultMessage: "View message source"});
} else {

View File

@ -144,10 +144,8 @@ function message_hover($message_row) {
// But the message edit hover icon is determined by whether the message is still editable
const editability = message_edit.get_editability(message);
const is_content_editable = editability === message_edit.editability_types.FULL;
const is_stream_editable =
message.is_stream && settings_data.user_can_move_messages_between_streams();
const can_move_message =
editability === message_edit.editability_types.TOPIC_ONLY || is_stream_editable;
const can_move_message = message_edit.can_move_message(message);
const args = {
is_content_editable: is_content_editable && !message.status_message,
can_move_message,