From e5f28ca78eb3aaf43c6d7a2e5e57907ddc38a039 Mon Sep 17 00:00:00 2001 From: Mohit Gupta Date: Tue, 12 Feb 2019 07:53:56 +0530 Subject: [PATCH] refactor: Rename locally_echoed to sent_by_this_client. This is a bit clearer, since we will soon want to pass this option for messages that could not be locally echoed due to markdown rendering. --- static/js/message_events.js | 4 ++-- static/js/notifications.js | 9 +++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/static/js/message_events.js b/static/js/message_events.js index 9e4ed95313..4f0c69089f 100644 --- a/static/js/message_events.js +++ b/static/js/message_events.js @@ -55,7 +55,7 @@ function maybe_add_narrowed_messages(messages, msg_list) { } -exports.insert_new_messages = function insert_new_messages(messages, locally_echoed) { +exports.insert_new_messages = function insert_new_messages(messages, sent_by_this_client) { messages = _.map(messages, message_store.add_message_metadata); unread.process_loaded_messages(messages); @@ -83,7 +83,7 @@ exports.insert_new_messages = function insert_new_messages(messages, locally_ech } - if (locally_echoed) { + if (sent_by_this_client) { var need_user_to_scroll = render_info && render_info.need_user_to_scroll; notifications.notify_local_mixes(messages, need_user_to_scroll); } diff --git a/static/js/notifications.js b/static/js/notifications.js index 488f365726..785bb5108e 100644 --- a/static/js/notifications.js +++ b/static/js/notifications.js @@ -588,12 +588,13 @@ exports.get_local_notify_mix_reason = function (message) { exports.notify_local_mixes = function (messages, need_user_to_scroll) { /* - This code should only be called when we are locally echoing - messages. It notifies users that their messages aren't - actually in the view that they composed to. + This code should only be called when we are displaying + messages sent by current client. It notifies users that + their messages aren't actually in the view that they + composed to. This code is called after we insert messages into our - message list widgets. All of the conditions here are + message list widgets. All of the conditions here are checkable locally, so we may want to execute this code earlier in the codepath at some point and possibly punt on local rendering.