From cae48d3faac831416847de6fefa5aaeedab73281 Mon Sep 17 00:00:00 2001 From: Karl Stolley Date: Thu, 6 Feb 2025 09:42:22 -0600 Subject: [PATCH] compose: Rename placeholder update function for clarity. --- web/src/compose_actions.ts | 2 +- web/src/compose_recipient.ts | 10 ++++++---- web/src/compose_setup.js | 6 +++--- web/src/server_events_dispatch.js | 2 +- web/src/ui_init.js | 2 +- web/tests/compose.test.cjs | 2 +- web/tests/compose_validate.test.cjs | 2 +- web/tests/composebox_typeahead.test.cjs | 2 +- 8 files changed, 15 insertions(+), 13 deletions(-) diff --git a/web/src/compose_actions.ts b/web/src/compose_actions.ts index 61446f7c14..24e47384f3 100644 --- a/web/src/compose_actions.ts +++ b/web/src/compose_actions.ts @@ -193,7 +193,7 @@ export let complete_starting_tasks = (opts: ComposeActionsOpts): void => { maybe_scroll_up_selected_message(opts); compose_fade.start_compose(opts.message_type); $(document).trigger(new $.Event("compose_started.zulip", opts)); - compose_recipient.update_placeholder_text(); + compose_recipient.update_compose_area_placeholder_text(); compose_recipient.update_narrow_to_recipient_visibility(); // We explicitly call this function here apart from compose_setup.js // as this helps to show banner when responding in an interleaved view. diff --git a/web/src/compose_recipient.ts b/web/src/compose_recipient.ts index 90b602cc8e..b8cc0cc877 100644 --- a/web/src/compose_recipient.ts +++ b/web/src/compose_recipient.ts @@ -175,7 +175,7 @@ function switch_message_type(message_type: MessageType): void { private_message_recipient: compose_state.private_message_recipient(), }; update_compose_for_message_type(opts); - update_placeholder_text(); + update_compose_area_placeholder_text(); compose_ui.set_focus(opts); } @@ -348,7 +348,7 @@ export function initialize(): void { $("#private_message_recipient").on("input", restore_placeholder_in_firefox_for_no_input); } -export let update_placeholder_text = (): void => { +export let update_compose_area_placeholder_text = (): void => { const $textarea: JQuery = $("textarea#compose-textarea"); // Change compose placeholder text only if compose box is open. if (!$textarea.is(":visible")) { @@ -375,8 +375,10 @@ export let update_placeholder_text = (): void => { compose_ui.autosize_textarea($textarea); }; -export function rewire_update_placeholder_text(value: typeof update_placeholder_text): void { - update_placeholder_text = value; +export function rewire_update_compose_area_placeholder_text( + value: typeof update_compose_area_placeholder_text, +): void { + update_compose_area_placeholder_text = value; } // This function addresses the issue of the placeholder not reappearing in Firefox diff --git a/web/src/compose_setup.js b/web/src/compose_setup.js index f5af56bd19..37eed0c0cb 100644 --- a/web/src/compose_setup.js +++ b/web/src/compose_setup.js @@ -582,7 +582,7 @@ export function initialize() { }); $("textarea#compose-textarea").on("focus", () => { - compose_recipient.update_placeholder_text(); + compose_recipient.update_compose_area_placeholder_text(); if (narrow_state.narrowed_by_reply()) { compose_notifications.maybe_show_one_time_non_interleaved_view_messages_fading_banner(); } else { @@ -604,11 +604,11 @@ export function initialize() { }); $("input#stream_message_recipient_topic").on("focus", () => { - compose_recipient.update_placeholder_text(); + compose_recipient.update_compose_area_placeholder_text(); }); $("input#stream_message_recipient_topic").on("input", () => { - compose_recipient.update_placeholder_text(); + compose_recipient.update_compose_area_placeholder_text(); }); $("body").on("click", ".formatting_button", function (e) { diff --git a/web/src/server_events_dispatch.js b/web/src/server_events_dispatch.js index b0585cf803..225eaa6664 100644 --- a/web/src/server_events_dispatch.js +++ b/web/src/server_events_dispatch.js @@ -1056,7 +1056,7 @@ export function dispatch_normal_event(event) { // Update the status text in compose box placeholder when opened to self. if (compose_pm_pill.get_user_ids().includes(event.user_id)) { - compose_recipient.update_placeholder_text(); + compose_recipient.update_compose_area_placeholder_text(); } } diff --git a/web/src/ui_init.js b/web/src/ui_init.js index 28cd89513f..4c7218beac 100644 --- a/web/src/ui_init.js +++ b/web/src/ui_init.js @@ -569,7 +569,7 @@ export function initialize_everything(state_data) { compose_recipient.initialize(); compose_pm_pill.initialize({ on_pill_create_or_remove() { - compose_recipient.update_placeholder_text(); + compose_recipient.update_compose_area_placeholder_text(); compose_recipient.check_posting_policy_for_compose_box(); }, }); diff --git a/web/tests/compose.test.cjs b/web/tests/compose.test.cjs index e2036c05c2..6bf9249fa8 100644 --- a/web/tests/compose.test.cjs +++ b/web/tests/compose.test.cjs @@ -822,7 +822,7 @@ test_ui("on_events", ({override, override_rewire}) => { (function test_undo_markdown_preview_clicked() { fake_compose_box.show_message_preview(); - override_rewire(compose_recipient, "update_placeholder_text", noop); + override_rewire(compose_recipient, "update_compose_area_placeholder_text", noop); override(narrow_state, "narrowed_by_reply", () => true); override( compose_notifications, diff --git a/web/tests/compose_validate.test.cjs b/web/tests/compose_validate.test.cjs index 835f3cd01f..afe9373c50 100644 --- a/web/tests/compose_validate.test.cjs +++ b/web/tests/compose_validate.test.cjs @@ -165,7 +165,7 @@ function initialize_pm_pill(mock_template) { $("#private_message_recipient").before = noop; compose_pm_pill.initialize({ - on_pill_create_or_remove: compose_recipient.update_placeholder_text, + on_pill_create_or_remove: compose_recipient.update_compose_area_placeholder_text, }); $("#zephyr-mirror-error").is = noop; diff --git a/web/tests/composebox_typeahead.test.cjs b/web/tests/composebox_typeahead.test.cjs index 6d68c80c81..f2de22ac5c 100644 --- a/web/tests/composebox_typeahead.test.cjs +++ b/web/tests/composebox_typeahead.test.cjs @@ -1087,7 +1087,7 @@ test("initialize", ({override, override_rewire, mock_template}) => { }, })); compose_pm_pill.initialize({ - on_pill_create_or_remove: compose_recipient.update_placeholder_text, + on_pill_create_or_remove: compose_recipient.update_compose_area_placeholder_text, }); let expected_value;