From 2451002e3b4934f293a56a063f9bce5b69b02562 Mon Sep 17 00:00:00 2001 From: Sahil Batra Date: Thu, 13 Oct 2022 17:34:14 +0530 Subject: [PATCH] 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. --- static/js/popovers.js | 9 +++------ static/js/ui_init.js | 6 ++---- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/static/js/popovers.js b/static/js/popovers.js index 079063ccf9..c59c42e425 100644 --- a/static/js/popovers.js +++ b/static/js/popovers.js @@ -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 { diff --git a/static/js/ui_init.js b/static/js/ui_init.js index 9cb1850f41..61c5d8a4f4 100644 --- a/static/js/ui_init.js +++ b/static/js/ui_init.js @@ -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,