diff --git a/static/js/compose_fade.js b/static/js/compose_fade.js index 6a3729a527..351c7e0ef9 100644 --- a/static/js/compose_fade.js +++ b/static/js/compose_fade.js @@ -110,6 +110,28 @@ exports.update_message_list = function () { } }; +exports.update_rendered_messages = function (messages, get_element) { + if (_want_normal_display()) { + return; + } + + // This loop is superficially similar to some code in _fade_messages, but an + // important difference here is that we look at each message individually, whereas + // the other code takes advantage of blocks beneath recipient bars. + _.each(messages, function (message) { + var elt = get_element(message); + var should_fade_message = !util.same_recipient(focused_recipient, message); + + if (should_fade_message) { + elt.removeClass("unfaded").addClass("faded"); + } else { + elt.removeClass("faded").addClass("unfaded"); + } + }); + + ui.update_floating_recipient_bar(); +}; + return exports; }()); diff --git a/static/js/message_list.js b/static/js/message_list.js index 99cce9d425..b0e4928065 100644 --- a/static/js/message_list.js +++ b/static/js/message_list.js @@ -621,8 +621,17 @@ MessageList.prototype = { this.select_id(this._selected_id, {from_rendering: true}); } - // Re-add the fading of messages that is lost when we re-render. - compose_fade.update_faded_messages(); + if (this === current_msg_list) { + // We don't have a Message class, but we can at least hide the messy details + // of rows.js from compose_fade. We provide a callback function to be lazy-- + // compose_fade may not actually need the elements depending on its internal + // state. + var get_element = function (message) { + return rows.get(message.id, table_name); + }; + + compose_fade.update_rendered_messages(messages, get_element); + } if (this === current_msg_list && messages_are_new) { this._maybe_autoscroll(rendered_elems);