mirror of
https://github.com/zulip/zulip.git
synced 2025-10-23 04:52:12 +00:00
move_topic_modal: Only include messages senders in warning banner.
Only participants who sent the messages being moved should appear in the warning banner.
This commit is contained in:
@@ -516,23 +516,55 @@ export async function build_move_topic_to_stream_popover(
|
|||||||
}
|
}
|
||||||
|
|
||||||
let curr_selected_stream: number;
|
let curr_selected_stream: number;
|
||||||
// Warn if any of current topic participants are NOT subscribed
|
|
||||||
// to the destination stream.
|
|
||||||
async function warn_unsubscribed_participants(destination_stream_id: number): Promise<void> {
|
|
||||||
$("#move_topic_modal .unsubscribed-participants-warning").remove();
|
|
||||||
|
|
||||||
// Do nothing if it's the same stream.
|
function get_messages_to_be_moved(
|
||||||
if (destination_stream_id === current_stream_id) {
|
propagate_mode: string,
|
||||||
return;
|
selected_message: Message | undefined,
|
||||||
}
|
): Message[] {
|
||||||
|
const all_locally_cached_conversation_messages = message_util.get_loaded_messages_in_topic(
|
||||||
const locally_cached_conversation_messages = message_util.get_loaded_messages_in_topic(
|
|
||||||
current_stream_id,
|
current_stream_id,
|
||||||
topic_name,
|
topic_name,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// It's move-topic modal, so no message is selected.
|
||||||
|
if (selected_message === undefined) {
|
||||||
|
return all_locally_cached_conversation_messages;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Move only selected message.
|
||||||
|
if (propagate_mode === "change_one") {
|
||||||
|
return [selected_message];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Move selected message and all its following messages.
|
||||||
|
if (propagate_mode === "change_later") {
|
||||||
|
return all_locally_cached_conversation_messages.filter(
|
||||||
|
(msg) => msg.id >= selected_message.id,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Move all messages in topic.
|
||||||
|
return all_locally_cached_conversation_messages;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Warn if any sender of the messages being moved is NOT subscribed
|
||||||
|
// to the destination stream.
|
||||||
|
async function warn_unsubscribed_participants(selected_propagate_mode: string): Promise<void> {
|
||||||
|
$("#move_topic_modal .unsubscribed-participants-warning").remove();
|
||||||
|
|
||||||
|
const destination_stream_id = stream_widget_value;
|
||||||
|
|
||||||
|
// Do nothing if it's the same stream.
|
||||||
|
if (destination_stream_id === undefined || destination_stream_id === current_stream_id) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Only participants who sent the messages being moved should appear in the banner,
|
||||||
|
// so we fetch those messages first.
|
||||||
|
const messages_to_be_moved = get_messages_to_be_moved(selected_propagate_mode, message);
|
||||||
|
|
||||||
const active_human_participant_ids = new ConversationParticipants(
|
const active_human_participant_ids = new ConversationParticipants(
|
||||||
locally_cached_conversation_messages,
|
messages_to_be_moved,
|
||||||
).visible();
|
).visible();
|
||||||
|
|
||||||
const unsubscribed_participant_ids: number[] = [];
|
const unsubscribed_participant_ids: number[] = [];
|
||||||
@@ -587,6 +619,7 @@ export async function build_move_topic_to_stream_popover(
|
|||||||
: null,
|
: null,
|
||||||
hide_close_button: true,
|
hide_close_button: true,
|
||||||
stream: destination_stream,
|
stream: destination_stream,
|
||||||
|
selected_propagate_mode,
|
||||||
unsubscribed_participant_formatted_names_list,
|
unsubscribed_participant_formatted_names_list,
|
||||||
unsubscribed_participants_count,
|
unsubscribed_participants_count,
|
||||||
few_unsubscribed_participants,
|
few_unsubscribed_participants,
|
||||||
@@ -811,7 +844,8 @@ export async function build_move_topic_to_stream_popover(
|
|||||||
render_selected_stream();
|
render_selected_stream();
|
||||||
maybe_show_topic_already_exists_warning();
|
maybe_show_topic_already_exists_warning();
|
||||||
update_topic_input_placeholder_visibility(topic_input_value);
|
update_topic_input_placeholder_visibility(topic_input_value);
|
||||||
void warn_unsubscribed_participants(stream_widget_value);
|
const selected_propagate_mode = String($("#message_move_select_options").val());
|
||||||
|
void warn_unsubscribed_participants(selected_propagate_mode);
|
||||||
|
|
||||||
dropdown.hide();
|
dropdown.hide();
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
@@ -1050,6 +1084,7 @@ export async function build_move_topic_to_stream_popover(
|
|||||||
$("#message_move_select_options").on("change", function () {
|
$("#message_move_select_options").on("change", function () {
|
||||||
selected_option = String($(this).val());
|
selected_option = String($(this).val());
|
||||||
last_propagate_mode_for_conversation.set(conversation_key, selected_option);
|
last_propagate_mode_for_conversation.set(conversation_key, selected_option);
|
||||||
|
void warn_unsubscribed_participants(selected_option);
|
||||||
maybe_show_topic_already_exists_warning();
|
maybe_show_topic_already_exists_warning();
|
||||||
update_move_messages_count_text(selected_option, message?.id);
|
update_move_messages_count_text(selected_option, message?.id);
|
||||||
});
|
});
|
||||||
|
@@ -1,6 +1,13 @@
|
|||||||
{{#> modal_banner . }}
|
{{#> modal_banner . }}
|
||||||
<p class="banner_message">
|
<p class="banner_message">
|
||||||
{{#if few_unsubscribed_participants}}
|
{{#if (eq selected_propagate_mode "change_one")}}
|
||||||
|
{{#tr}}
|
||||||
|
Message sender <z-user-names></z-user-names> is not subscribed to <z-stream></z-stream>.
|
||||||
|
{{#*inline "z-user-names"}}({{{unsubscribed_participant_formatted_names_list}}}){{/inline}}
|
||||||
|
{{#*inline "z-stream"}}<strong>{{> ../inline_decorated_channel_name stream=stream show_colored_icon=true}}</strong>{{/inline}}
|
||||||
|
{{/tr}}
|
||||||
|
|
||||||
|
{{else if few_unsubscribed_participants}}
|
||||||
{{#tr}}
|
{{#tr}}
|
||||||
Some topic participants <z-user-names></z-user-names> are not subscribed to <z-stream></z-stream>.
|
Some topic participants <z-user-names></z-user-names> are not subscribed to <z-stream></z-stream>.
|
||||||
{{#*inline "z-user-names"}}({{{unsubscribed_participant_formatted_names_list}}}){{/inline}}
|
{{#*inline "z-user-names"}}({{{unsubscribed_participant_formatted_names_list}}}){{/inline}}
|
||||||
|
Reference in New Issue
Block a user