From e5b216fc647c7b313fdba370d41b360e73f418fa Mon Sep 17 00:00:00 2001 From: Riken Shah Date: Mon, 2 Aug 2021 14:55:27 +0000 Subject: [PATCH] compose: Update status text in placeholder instantly after it's updated. When compose box is opened to self and the user updates the status, it should instantly update the status text in a placeholder. --- frontend_tests/node_tests/dispatch.js | 2 ++ static/js/server_events_dispatch.js | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/frontend_tests/node_tests/dispatch.js b/frontend_tests/node_tests/dispatch.js index 8134870f6a..c4cf323889 100644 --- a/frontend_tests/node_tests/dispatch.js +++ b/frontend_tests/node_tests/dispatch.js @@ -87,6 +87,7 @@ const message_store = zrequire("message_store"); const people = zrequire("people"); const starred_messages = zrequire("starred_messages"); const user_status = zrequire("user_status"); +const compose_pm_pill = zrequire("compose_pm_pill"); const emoji = zrequire("../shared/js/emoji"); @@ -934,6 +935,7 @@ run_test("user_status", ({override}) => { { const stub = make_stub(); override(activity, "redraw_user", stub.f); + override(compose_pm_pill, "get_user_ids", () => [event.user_id]); dispatch(event); assert.equal(stub.num_calls, 1); const args = stub.get_args("user_id"); diff --git a/static/js/server_events_dispatch.js b/static/js/server_events_dispatch.js index a083d87e75..8563bb9047 100644 --- a/static/js/server_events_dispatch.js +++ b/static/js/server_events_dispatch.js @@ -9,7 +9,9 @@ import * as attachments_ui from "./attachments_ui"; import * as blueslip from "./blueslip"; import * as bot_data from "./bot_data"; import * as compose from "./compose"; +import * as compose_actions from "./compose_actions"; import * as compose_fade from "./compose_fade"; +import * as compose_pm_pill from "./compose_pm_pill"; import * as composebox_typeahead from "./composebox_typeahead"; import * as emoji_picker from "./emoji_picker"; import * as giphy from "./giphy"; @@ -710,6 +712,11 @@ export function dispatch_normal_event(event) { status_text: event.status_text, }); activity.redraw_user(event.user_id); + + // Update the status text in compose box placeholder when opened to self. + if (compose_pm_pill.get_user_ids().includes(event.user_id)) { + compose_actions.update_placeholder_text(); + } } if (event.emoji_name !== undefined) {