From a54704383103812d5d682f06df27f3855f82ec5f Mon Sep 17 00:00:00 2001 From: Zev Benjamin Date: Tue, 25 Feb 2014 18:19:20 -0500 Subject: [PATCH] Fix search highlighting for message content and topics Previously topics weren't being highlighted at all and messages had their highlighting persist across different narrows (because we were only checking whether the message object had a match_content property, not whether it should currently be used). (imported from commit 44c91c6d5799dcdf765e19e1a17bd727ce80c918) --- static/js/message_list_view.js | 4 +++- static/templates/message_group.handlebars | 4 ++-- static/templates/single_message.handlebars | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/static/js/message_list_view.js b/static/js/message_list_view.js index 336d7aeb86..0acb1a5de6 100644 --- a/static/js/message_list_view.js +++ b/static/js/message_list_view.js @@ -126,6 +126,7 @@ MessageListView.prototype = { current_group.color_class = stream_color.get_color_class(current_group.background_color); current_group.invite_only = stream_data.get_invite_only(first_message.stream); current_group.subject = first_message.subject; + current_group.match_subject = first_message.match_subject; } else if (current_group.is_private) { current_group.pm_with_url = first_message.pm_with_url; current_group.display_reply_to = first_message.display_reply_to; @@ -245,7 +246,8 @@ MessageListView.prototype = { } var rendered_groups = $(templates.render('message_group', { - message_groups: new_message_groups + message_groups: new_message_groups, + use_match_properties: self.list.filter.is_search() })); var rendered_messages = []; diff --git a/static/templates/message_group.handlebars b/static/templates/message_group.handlebars index b5372d58bc..8dd6d42ce1 100644 --- a/static/templates/message_group.handlebars +++ b/static/templates/message_group.handlebars @@ -37,7 +37,7 @@ - {{#if ../../../../../use_match_properties}} + {{#if ../../../use_match_properties}} {{{match_subject}}} {{else}} {{subject}} @@ -82,7 +82,7 @@ {{/if}} {{#each messages}} {{#with this}} - {{partial "single_message"}} + {{partial "single_message" "use_match_properties" ../../../../use_match_properties}} {{/with}} {{/each}} diff --git a/static/templates/single_message.handlebars b/static/templates/single_message.handlebars index 22482f8043..d14e5e159b 100644 --- a/static/templates/single_message.handlebars +++ b/static/templates/single_message.handlebars @@ -30,7 +30,7 @@ -
{{#unless status_message}}{{#if match_content}}{{{match_content}}}{{else}}{{{content}}}{{/if}}{{/unless}}
+
{{#unless status_message}}{{#if use_match_properties}}{{{match_content}}}{{else}}{{{content}}}{{/if}}{{/unless}}
{{#if last_edit_timestr}} {{#unless include_sender}}
EDITED