compose-closed: Fix updating buttons when not in DM narrow.

When processing a server event or an empty message fetch,
we were incorrectly updating the closed new conversation
button attribute, "data-conversation-type" to be "direct"
without checking to see if the current narrow filter was
actually a direct message view.

Adds a helper function that checks the current filter for
contains_only_private_messages and then calls
compose_closed_ui.update_buttons_for_private when true.

That's the same check that's used in
message_view.handle_post_view_change when
compose_closed_ui.update_buttons_for_private is called,
so we're consistently using the same check when updating
the closed compose box buttons for this state.
This commit is contained in:
Lauryn Menard
2025-09-03 15:43:09 +02:00
committed by Tim Abbott
parent c1480bec36
commit 1c7e4a5e09
3 changed files with 9 additions and 2 deletions

View File

@@ -208,6 +208,13 @@ export function update_buttons_for_non_specific_views(): void {
set_standard_text_for_reply_button(); set_standard_text_for_reply_button();
} }
export function maybe_update_buttons_for_dm_recipient(): void {
const filter = narrow_state.filter();
if (filter?.contains_only_private_messages()) {
update_buttons_for_private();
}
}
function set_reply_button_label(label: string): void { function set_reply_button_label(label: string): void {
$("#left_bar_compose_reply_button_big").text(label); $("#left_bar_compose_reply_button_big").text(label);
} }

View File

@@ -128,7 +128,7 @@ export function fetch_more_if_required_for_current_msg_list(
// no messages to display in this narrow. // no messages to display in this narrow.
narrow_banner.show_empty_narrow_message(message_lists.current.data.filter); narrow_banner.show_empty_narrow_message(message_lists.current.data.filter);
message_lists.current.update_trailing_bookend(); message_lists.current.update_trailing_bookend();
compose_closed_ui.update_buttons_for_private(); compose_closed_ui.maybe_update_buttons_for_dm_recipient();
compose_recipient.check_posting_policy_for_compose_box(); compose_recipient.check_posting_policy_for_compose_box();
} }

View File

@@ -408,7 +408,7 @@ export function dispatch_normal_event(event) {
key === "direct_message_permission_group" key === "direct_message_permission_group"
) { ) {
settings_org.check_disable_direct_message_initiator_group_widget(); settings_org.check_disable_direct_message_initiator_group_widget();
compose_closed_ui.update_buttons_for_private(); compose_closed_ui.maybe_update_buttons_for_dm_recipient();
compose_recipient.check_posting_policy_for_compose_box(); compose_recipient.check_posting_policy_for_compose_box();
} }