diff --git a/zephyr/static/js/message_list.js b/zephyr/static/js/message_list.js index 01be0d60e3..1309988659 100644 --- a/zephyr/static/js/message_list.js +++ b/zephyr/static/js/message_list.js @@ -383,7 +383,8 @@ MessageList.prototype = { var rendered_elems = $(templates.render('message', { messages: messages_to_render, - include_layout_row: (table.find('tr:first').length === 0) + include_layout_row: (table.find('tr:first').length === 0), + use_match_properties: this.filter.is_search() })); $.each(rendered_elems, function (index, elem) { @@ -395,10 +396,6 @@ MessageList.prototype = { if (ids_where_next_is_same_sender[id]) { row.find('.messagebox').addClass("next_is_same_sender"); } - if (self === narrowed_msg_list) { - // If narrowed, we may need to highlight the message - search.maybe_highlight_message(row); - } }); // The message that was last before this batch came in has to be diff --git a/zephyr/static/js/narrow.js b/zephyr/static/js/narrow.js index 78c538708a..ad7ee4c42d 100644 --- a/zephyr/static/js/narrow.js +++ b/zephyr/static/js/narrow.js @@ -36,16 +36,20 @@ Filter.prototype = { } }, - can_apply_locally: function Filter_can_apply_locally() { - var retval = true; + is_search: function Filter_is_search() { + var retval = false; $.each(this._operators, function (idx, elem) { if (elem[0] === "search") { - retval = false; + retval = true; return false; }}); return retval; }, + can_apply_locally: function Filter_can_apply_locally() { + return ! this.is_search(); + }, + _canonicalize_operators: function Filter__canonicalize_operators(operators_mixed_case) { var new_operators = []; // We don't use $.map because it flattens returned arrays. @@ -424,7 +428,6 @@ exports.activate = function (operators, opts) { } return undefined; } - search.update_highlighting(extract_search_terms(operators)); // Put the narrow operators in the URL fragment. // Disabled when the URL fragment was the source @@ -528,8 +531,6 @@ exports.deactivate = function () { // view since leaving it the old selected id might no longer be there home_msg_list.select_id(home_msg_list.selected_id(), {then_scroll: true, use_closest: true}); - search.clear_highlighting(); - hashchange.save_narrow(); $("ul.filters li").removeClass('active-filter active-subject-filter'); diff --git a/zephyr/static/js/search.js b/zephyr/static/js/search.js index 4426fa3b96..5869a6eb2c 100644 --- a/zephyr/static/js/search.js +++ b/zephyr/static/js/search.js @@ -268,35 +268,6 @@ function match_on_visible_text(row, search_term) { .text().toLowerCase().indexOf(search_term) !== -1; } -exports.update_highlighting = function(search_term) { - if (current_search_term !== undefined) { - exports.clear_highlighting(); - } - current_search_term = search_term; - if (search_term === undefined) { - return; - } - - var focused_table = $('table.focused_table'); - focused_table.find('.message_row').each(function (index, row) { - row = $(row); - exports.maybe_highlight_message(row); - }); -}; - -exports.maybe_highlight_message = function(row) { - row.find('.message_content').highlight(current_search_term); - if (current_msg_list.get(rows.id(row)).type === "stream") { - row = row.prev('.recipient_row'); - row.find('.message_label_clickable').highlight(current_search_term); - } -}; - -exports.clear_highlighting = function () { - current_search_term = undefined; - return $(".message_content .message_label_clickable").removeHighlight(); -}; - exports.focus_search = function () { // The search bar is not focused yet, but will be. update_buttons_with_focus(true); diff --git a/zephyr/static/js/zephyr.js b/zephyr/static/js/zephyr.js index 9342ef330f..60ad3a8ef9 100644 --- a/zephyr/static/js/zephyr.js +++ b/zephyr/static/js/zephyr.js @@ -501,8 +501,15 @@ function process_message_for_recent_subjects(message) { } function add_message_metadata(message, dummy) { - if (all_msg_list.get(message.id)) { - return all_msg_list.get(message.id); + var cached_msg = all_msg_list.get(message.id); + if (cached_msg !== undefined) { + // Copy the match subject and content over if they exist on + // the new message + if (message.match_subject !== undefined) { + cached_msg.match_subject = message.match_subject; + cached_msg.match_content = message.match_content; + } + return cached_msg; } get_updates_params.last = Math.max(get_updates_params.last || 0, message.id); diff --git a/zephyr/static/templates/message.handlebars b/zephyr/static/templates/message.handlebars index 8a296cfa7a..721df3b83b 100644 --- a/zephyr/static/templates/message.handlebars +++ b/zephyr/static/templates/message.handlebars @@ -41,7 +41,7 @@ title="Narrow to stream "{{display_recipient}}"">{{display_recipient}} > + title="Narrow to stream "{{display_recipient}}", subject "{{subject}}"">{{#if ../../../../use_match_properties}}{{{match_subject}}}{{else}}{{subject}}{{/if}} {{else}} @@ -84,7 +84,7 @@ -
+