Files
zulip/static/js/starred_messages_ui.js
Abhijeet Prasad Bodas ded3d94f62 starred messages: Clean up "unstar all in topic" warning.
The dialog now shows `stream > topic` instead of
just the topic.
This creates a new tiny widget for this purpose,
which can be reused in other places too.

The `undefined` case is probably very unlikely, but
if the `stream_id` is bad, after the user confirms,
the request will fail on the backend, which could
confuse the user, since there will be no changes to
the starred messages in view.
So, we don't open the confirmation dialog at all in
such cases.
2021-04-29 16:43:39 -07:00

48 lines
1.5 KiB
JavaScript

import $ from "jquery";
import render_confirm_unstar_all_messages from "../templates/confirm_unstar_all_messages.hbs";
import render_confirm_unstar_all_messages_in_topic from "../templates/confirm_unstar_all_messages_in_topic.hbs";
import * as confirm_dialog from "./confirm_dialog";
import {$t_html} from "./i18n";
import * as message_flags from "./message_flags";
import * as stream_data from "./stream_data";
export function confirm_unstar_all_messages() {
const modal_parent = $(".left-sidebar-modal-holder");
const html_body = render_confirm_unstar_all_messages();
confirm_dialog.launch({
parent: modal_parent,
html_heading: $t_html({defaultMessage: "Unstar all messages"}),
html_body,
html_yes_button: $t_html({defaultMessage: "Confirm"}),
on_click: message_flags.unstar_all_messages,
});
}
export function confirm_unstar_all_messages_in_topic(stream_id, topic) {
function on_click() {
message_flags.unstar_all_messages_in_topic(stream_id, topic);
}
const stream_name = stream_data.maybe_get_stream_name(stream_id);
if (stream_name === undefined) {
return;
}
const modal_parent = $(".left-sidebar-modal-holder");
const html_body = render_confirm_unstar_all_messages_in_topic({
stream_name,
topic,
});
confirm_dialog.launch({
parent: modal_parent,
html_heading: $t_html({defaultMessage: "Unstar messages in topic"}),
html_body,
html_yes_button: $t_html({defaultMessage: "Confirm"}),
on_click,
});
}