message: Show error while resolving/unresolving topic.

We were not showing the error, if any, when resolving and
unresolving the topic using topic popover in left sidebar
or using the banner in compose box. This commit adds code
to show the error in the message feed where we show other
errors like connection error, etc.
This commit is contained in:
Sahil Batra 2023-05-24 17:12:18 +05:30 committed by Tim Abbott
parent 457ff73082
commit 7f4f905ec8
4 changed files with 16 additions and 4 deletions

View File

@ -523,7 +523,7 @@ export function initialize() {
const topic_name = $target.attr("data-topic-name");
message_edit.with_first_message_id(stream_id, topic_name, (message_id) => {
message_edit.toggle_resolve_topic(message_id, topic_name);
message_edit.toggle_resolve_topic(message_id, topic_name, true);
compose_validate.clear_topic_resolved_warning(true);
});
},

View File

@ -697,7 +697,7 @@ function handle_resolve_topic_failure_due_to_time_limit(topic_is_resolved) {
});
}
export function toggle_resolve_topic(message_id, old_topic_name) {
export function toggle_resolve_topic(message_id, old_topic_name, report_errors_in_global_banner) {
let new_topic_name;
const topic_is_resolved = resolved_topic.is_resolved(old_topic_name);
if (topic_is_resolved) {
@ -719,6 +719,12 @@ export function toggle_resolve_topic(message_id, old_topic_name) {
error(xhr) {
if (xhr.responseJSON.code === "MOVE_MESSAGES_TIME_LIMIT_EXCEEDED") {
handle_resolve_topic_failure_due_to_time_limit(topic_is_resolved);
return;
}
if (report_errors_in_global_banner) {
const error_msg = JSON.parse(xhr.responseText).msg;
ui_report.generic_embed_error(error_msg, 3500);
}
},
});

View File

@ -535,7 +535,7 @@ export function initialize() {
$popper.one("click", ".sidebar-popover-toggle-resolved", () => {
message_edit.with_first_message_id(stream_id, topic_name, (message_id) => {
message_edit.toggle_resolve_topic(message_id, topic_name);
message_edit.toggle_resolve_topic(message_id, topic_name, true);
});
instance.hide();

View File

@ -64,11 +64,17 @@ export function success(response_html: string, $status_box: JQuery, remove_after
message(response_html, $status_box, "alert-success", remove_after);
}
export function generic_embed_error(error_html: string): void {
export function generic_embed_error(error_html: string, remove_after: number): void {
const $alert = $("<div>").addClass(["alert", "home-error-bar", "show"]);
const $exit = $("<div>").addClass("exit");
$(".alert-box").append($alert.append($exit, $("<div>").addClass("content").html(error_html)));
if (remove_after !== undefined) {
setTimeout(() => {
$alert.fadeOut(400);
}, remove_after);
}
}
export function generic_row_button_error(xhr: JQuery.jqXHR, $btn: JQuery): void {