From 0d25baedfad2ededa8090490fe61a016f8db43cb Mon Sep 17 00:00:00 2001 From: Siddharth Varshney Date: Thu, 7 Mar 2019 04:16:53 +0530 Subject: [PATCH] compose: Fix narrow button text when switching to PM. This changes the "new private message" button to be instead "new conversation" when looking at PMs, to avoid confusion that the button was the right thing to do to reply to the current private message conversation. Fixes #11679. --- frontend_tests/node_tests/compose.js | 6 +++-- frontend_tests/node_tests/narrow_activate.js | 6 ++--- static/js/compose.js | 27 ++++++++++++++------ static/js/narrow.js | 6 ++--- 4 files changed, 29 insertions(+), 16 deletions(-) diff --git a/frontend_tests/node_tests/compose.js b/frontend_tests/node_tests/compose.js index 74decbf9bf..bd0835a0d8 100644 --- a/frontend_tests/node_tests/compose.js +++ b/frontend_tests/node_tests/compose.js @@ -1690,9 +1690,11 @@ run_test('nonexistent_stream_reply_error', () => { run_test('narrow_button_titles', () => { util.is_mobile = () => { return false; }; - compose.update_stream_button_for_private(); + compose.update_closed_compose_buttons_for_private(); assert.equal($("#left_bar_compose_stream_button_big").text(), i18n.t("New stream message")); + assert.equal($("#left_bar_compose_private_button_big").text(), i18n.t("New conversation")); - compose.update_stream_button_for_stream(); + compose.update_closed_compose_buttons_for_stream(); assert.equal($("#left_bar_compose_stream_button_big").text(), i18n.t("New topic")); + assert.equal($("#left_bar_compose_private_button_big").text(), i18n.t("New private message")); }); diff --git a/frontend_tests/node_tests/narrow_activate.js b/frontend_tests/node_tests/narrow_activate.js index 3ead5f0bec..5ed99e3d14 100644 --- a/frontend_tests/node_tests/narrow_activate.js +++ b/frontend_tests/node_tests/narrow_activate.js @@ -81,8 +81,8 @@ function test_helper() { stub('typing_events', 'render_notifications_for_narrow'); stub('ui_util', 'change_tab_to'); stub('unread_ops', 'process_visible'); - stub('compose', 'update_stream_button_for_stream'); - stub('compose', 'update_stream_button_for_private'); + stub('compose', 'update_closed_compose_buttons_for_stream'); + stub('compose', 'update_closed_compose_buttons_for_private'); stub('notifications', 'hide_history_limit_message'); blueslip.debug = noop; @@ -203,7 +203,7 @@ run_test('basics', () => { 'message_scroll.hide_indicators', 'unread_ops.process_visible', 'hashchange.save_narrow', - 'compose.update_stream_button_for_stream', + 'compose.update_closed_compose_buttons_for_stream', 'search.update_button_visibility', 'compose_actions.on_narrow', 'top_left_corner.handle_narrow_activated', diff --git a/static/js/compose.js b/static/js/compose.js index ae73364e39..0463eecd9c 100644 --- a/static/js/compose.js +++ b/static/js/compose.js @@ -106,16 +106,27 @@ function update_stream_button(btn_text, title) { $("#left_bar_compose_stream_button_big").prop("title", title); } -exports.update_stream_button_for_private = function () { - var text = i18n.t("New stream message"); - var title = text + " (c)"; - update_stream_button(text, title); +function update_conversation_button(btn_text, title) { + $("#left_bar_compose_private_button_big").text(btn_text); + $("#left_bar_compose_private_button_big").prop("title", title); +} + +exports.update_closed_compose_buttons_for_private = function () { + var text_stream = i18n.t("New stream message"); + var title_stream = text_stream + " (c)"; + var text_conversation = i18n.t("New conversation"); + var title_conversation = text_conversation + " (c)"; + update_stream_button(text_stream, title_stream); + update_conversation_button(text_conversation, title_conversation); }; -exports.update_stream_button_for_stream = function () { - var text = i18n.t("New topic"); - var title = text + " (c)"; - update_stream_button(text, title); +exports.update_closed_compose_buttons_for_stream = function () { + var text_stream = i18n.t("New topic"); + var title_stream = text_stream + " (c)"; + var text_conversation = i18n.t("New private message"); + var title_conversation = text_conversation + " (c)"; + update_stream_button(text_stream, title_stream); + update_conversation_button(text_conversation, title_conversation); }; function update_fade() { diff --git a/static/js/narrow.js b/static/js/narrow.js index 2a77a73a3b..d7fbcba7ff 100644 --- a/static/js/narrow.js +++ b/static/js/narrow.js @@ -255,9 +255,9 @@ exports.activate = function (raw_operators, opts) { if (filter.has_operator("is") && filter.operands("is")[0] === "private" || filter.has_operator("pm-with") || filter.has_operator("group-pm-with")) { - compose.update_stream_button_for_private(); + compose.update_closed_compose_buttons_for_private(); } else { - compose.update_stream_button_for_stream(); + compose.update_closed_compose_buttons_for_stream(); } // Put the narrow operators in the search bar. @@ -651,7 +651,7 @@ function handle_post_narrow_deactivate_processes() { top_left_corner.handle_narrow_deactivated(); stream_list.handle_narrow_deactivated(); - compose.update_stream_button_for_stream(); + compose.update_closed_compose_buttons_for_stream(); message_edit.handle_narrow_deactivated(); widgetize.set_widgets_for_list(); typing_events.render_notifications_for_narrow();