message_edit: Editing topic from message header should move all messages.

Editing topic from message header should now move all the messages in
the topic and not just the messages below the recipient bar.
This commit is contained in:
Sahil Batra 2023-04-20 13:37:54 +05:30 committed by Tim Abbott
parent 146f78a83d
commit 3992db5a19
1 changed files with 31 additions and 2 deletions

View File

@ -827,7 +827,7 @@ export function save_inline_topic_edit($row) {
const request = { const request = {
message_id: message.id, message_id: message.id,
topic: new_topic, topic: new_topic,
propagate_mode: "change_later", propagate_mode: "change_all",
send_notification_to_old_thread: false, send_notification_to_old_thread: false,
send_notification_to_new_thread: false, send_notification_to_new_thread: false,
}; };
@ -841,6 +841,34 @@ export function save_inline_topic_edit($row) {
}, },
error(xhr) { error(xhr) {
const $spinner = $row.find(".topic_edit_spinner"); const $spinner = $row.find(".topic_edit_spinner");
if (xhr.responseJSON.code === "MOVE_MESSAGES_TIME_LIMIT_EXCEEDED") {
const allowed_message_id = xhr.responseJSON.first_message_id_allowed_to_move;
const send_notification_to_old_thread = false;
const send_notification_to_new_thread = false;
// We are not changing stream in this UI.
const new_stream_id = undefined;
function handle_confirm() {
move_topic_containing_message_to_stream(
allowed_message_id,
new_stream_id,
new_topic,
send_notification_to_new_thread,
send_notification_to_old_thread,
"change_later",
);
}
const on_hide_callback = () => {
loading.destroy_indicator($spinner);
end_inline_topic_edit($row);
};
handle_message_move_failure_due_to_time_limit(
xhr,
handle_confirm,
on_hide_callback,
);
return;
}
loading.destroy_indicator($spinner); loading.destroy_indicator($spinner);
if (msg_list === message_lists.current) { if (msg_list === message_lists.current) {
message_id = rows.id_for_recipient_row($row); message_id = rows.id_for_recipient_row($row);
@ -1097,7 +1125,7 @@ export function handle_narrow_deactivated() {
} }
} }
function handle_message_move_failure_due_to_time_limit(xhr, handle_confirm) { function handle_message_move_failure_due_to_time_limit(xhr, handle_confirm, on_hide_callback) {
const total_messages_allowed_to_move = xhr.responseJSON.total_messages_allowed_to_move; const total_messages_allowed_to_move = xhr.responseJSON.total_messages_allowed_to_move;
const messages_allowed_to_move_text = $t( const messages_allowed_to_move_text = $t(
{ {
@ -1126,6 +1154,7 @@ function handle_message_move_failure_due_to_time_limit(xhr, handle_confirm) {
html_body, html_body,
on_click: handle_confirm, on_click: handle_confirm,
loading_spinner: true, loading_spinner: true,
on_hide: on_hide_callback,
}); });
} }