From a237963c906f43e7b6d0fd46a1a3e78d54699429 Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Fri, 28 Jun 2013 12:05:33 -0400 Subject: [PATCH] Fix buggy calculations of which messages get a footer. (imported from commit 14c942e8297b2385690bb3e679cca729afd9c52b) --- zephyr/static/js/message_list.js | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/zephyr/static/js/message_list.js b/zephyr/static/js/message_list.js index dd3cf4472b..ac7f270e82 100644 --- a/zephyr/static/js/message_list.js +++ b/zephyr/static/js/message_list.js @@ -298,6 +298,8 @@ MessageList.prototype = { if (util.same_recipient(prev, message) && self.collapse_messages && prev.historical === message.historical && !message.show_date) { current_group.push(message.id); + // prev is no longer the last element in this block + prev.include_footer = false; } else { if (current_group.length > 0) new_message_groups.push(current_group); @@ -306,8 +308,8 @@ MessageList.prototype = { // Add a space to the table, but not for the first element. message.include_recipient = true; message.include_bookend = (prev !== undefined); - if (prev) { - prev.include_footer = message.include_bookend; + if (prev !== undefined) { + prev.include_footer = true; } message.subscribed = false; message.unsubscribed = false; @@ -393,9 +395,13 @@ MessageList.prototype = { var row = rows.get(last_message_id, table_name); if (ids_where_next_is_same_sender[last_message_id]) { row.find('.messagebox').addClass("next_is_same_sender"); - if (this.get(last_message_id) && this.get(last_message_id).include_footer) { - row.removeClass('last_message'); - } + } + // We didn't actually rerender the original last message, + // but we might have set .include_footer=false for it in + // the above loop since it was the previous message for + // messages[0]. If so, we need to update the DOM. + if (this.get(last_message_id) && ! this.get(last_message_id).include_footer) { + row.removeClass('last_message'); } }