stream_popover: Handle no messages condition for a topic being moved.

Previously, when there were no messages in the topic being moved, the
banner in the move topic modal only showed a "Failed" error banner which
did not convey the actual error to the user. Also, a server call was
being made even when there were no messages in the topic being moved.

This commit explicitly handles the non-existent topic, prevents a call
to the server when the message_id is undefined, and displays a more
informative error banner to the user.
This commit is contained in:
Sayam Samal 2024-10-28 19:11:55 +05:30 committed by Tim Abbott
parent 858fdeee39
commit efa5b3cce1
1 changed files with 10 additions and 0 deletions

View File

@ -491,6 +491,16 @@ export async function build_move_topic_to_stream_popover(
current_stream_id,
old_topic_name,
(message_id) => {
if (message_id === undefined) {
// There are no messages in the given topic, so we show an error banner
// and return, preventing any attempts to move a non-existent topic.
dialog_widget.hide_dialog_spinner();
ui_report.client_error(
$t_html({defaultMessage: "There are no messages to move."}),
$("#move_topic_modal #dialog_error"),
);
return;
}
message_edit.move_topic_containing_message_to_stream(
message_id,
select_stream_id,