diff --git a/static/js/message_events.js b/static/js/message_events.js index 58fc8e928f..f2f72aa944 100644 --- a/static/js/message_events.js +++ b/static/js/message_events.js @@ -65,13 +65,15 @@ exports.insert_new_messages = function insert_new_messages(messages, local_id) { if (narrow_state.active()) { if (narrow_state.filter().can_apply_locally()) { message_util.add_messages(messages, message_list.narrowed, {messages_are_new: true}); - notifications.possibly_notify_new_messages_outside_viewport(messages, local_id); } else { // if we cannot apply locally, we have to wait for this callback to happen to notify maybe_add_narrowed_messages(messages, message_list.narrowed, true); } - } else { - notifications.possibly_notify_new_messages_outside_viewport(messages, local_id); + } + + + if (local_id) { + notifications.notify_local_mixes(messages); } activity.process_loaded_messages(messages); diff --git a/static/js/notifications.js b/static/js/notifications.js index aca614f747..6d9b5f1073 100644 --- a/static/js/notifications.js +++ b/static/js/notifications.js @@ -536,13 +536,18 @@ function get_message_header(message) { return "PM with " + message.display_reply_to; } -exports.possibly_notify_new_messages_outside_viewport = function (messages, local_id) { - // A warning should only be displayed when the message was sent by the user and - // this is the tab they sent it in. +exports.notify_local_mixes = function (messages) { + /* + 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. - if (local_id === undefined) { - return; - } + This code is called after we insert messages into our + 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. + */ _.each(messages, function (message) { if (!people.is_my_user_id(message.sender_id)) {