mirror of
https://github.com/zulip/zulip.git
synced 2025-11-14 19:06:09 +00:00
Use server-highlighted subject and content when narrowed to a search
(imported from commit 0579193da040db77f9c7937d3714cb9ffeaf7ed8)
This commit is contained in:
@@ -383,7 +383,8 @@ MessageList.prototype = {
|
|||||||
|
|
||||||
var rendered_elems = $(templates.render('message', {
|
var rendered_elems = $(templates.render('message', {
|
||||||
messages: messages_to_render,
|
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) {
|
$.each(rendered_elems, function (index, elem) {
|
||||||
@@ -395,10 +396,6 @@ MessageList.prototype = {
|
|||||||
if (ids_where_next_is_same_sender[id]) {
|
if (ids_where_next_is_same_sender[id]) {
|
||||||
row.find('.messagebox').addClass("next_is_same_sender");
|
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
|
// The message that was last before this batch came in has to be
|
||||||
|
|||||||
@@ -36,16 +36,20 @@ Filter.prototype = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
can_apply_locally: function Filter_can_apply_locally() {
|
is_search: function Filter_is_search() {
|
||||||
var retval = true;
|
var retval = false;
|
||||||
$.each(this._operators, function (idx, elem) {
|
$.each(this._operators, function (idx, elem) {
|
||||||
if (elem[0] === "search") {
|
if (elem[0] === "search") {
|
||||||
retval = false;
|
retval = true;
|
||||||
return false;
|
return false;
|
||||||
}});
|
}});
|
||||||
return retval;
|
return retval;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
can_apply_locally: function Filter_can_apply_locally() {
|
||||||
|
return ! this.is_search();
|
||||||
|
},
|
||||||
|
|
||||||
_canonicalize_operators: function Filter__canonicalize_operators(operators_mixed_case) {
|
_canonicalize_operators: function Filter__canonicalize_operators(operators_mixed_case) {
|
||||||
var new_operators = [];
|
var new_operators = [];
|
||||||
// We don't use $.map because it flattens returned arrays.
|
// We don't use $.map because it flattens returned arrays.
|
||||||
@@ -424,7 +428,6 @@ exports.activate = function (operators, opts) {
|
|||||||
}
|
}
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
search.update_highlighting(extract_search_terms(operators));
|
|
||||||
|
|
||||||
// Put the narrow operators in the URL fragment.
|
// Put the narrow operators in the URL fragment.
|
||||||
// Disabled when the URL fragment was the source
|
// 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
|
// 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});
|
home_msg_list.select_id(home_msg_list.selected_id(), {then_scroll: true, use_closest: true});
|
||||||
|
|
||||||
search.clear_highlighting();
|
|
||||||
|
|
||||||
hashchange.save_narrow();
|
hashchange.save_narrow();
|
||||||
|
|
||||||
$("ul.filters li").removeClass('active-filter active-subject-filter');
|
$("ul.filters li").removeClass('active-filter active-subject-filter');
|
||||||
|
|||||||
@@ -268,35 +268,6 @@ function match_on_visible_text(row, search_term) {
|
|||||||
.text().toLowerCase().indexOf(search_term) !== -1;
|
.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 () {
|
exports.focus_search = function () {
|
||||||
// The search bar is not focused yet, but will be.
|
// The search bar is not focused yet, but will be.
|
||||||
update_buttons_with_focus(true);
|
update_buttons_with_focus(true);
|
||||||
|
|||||||
@@ -501,8 +501,15 @@ function process_message_for_recent_subjects(message) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function add_message_metadata(message, dummy) {
|
function add_message_metadata(message, dummy) {
|
||||||
if (all_msg_list.get(message.id)) {
|
var cached_msg = all_msg_list.get(message.id);
|
||||||
return 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);
|
get_updates_params.last = Math.max(get_updates_params.last || 0, message.id);
|
||||||
|
|
||||||
|
|||||||
@@ -41,7 +41,7 @@
|
|||||||
title="Narrow to stream "{{display_recipient}}"">{{display_recipient}}</span>
|
title="Narrow to stream "{{display_recipient}}"">{{display_recipient}}</span>
|
||||||
>
|
>
|
||||||
<span class="message_label_clickable narrows_by_subject"
|
<span class="message_label_clickable narrows_by_subject"
|
||||||
title="Narrow to stream "{{display_recipient}}", subject "{{subject}}"">{{subject}}</span>
|
title="Narrow to stream "{{display_recipient}}", subject "{{subject}}"">{{#if ../../../../use_match_properties}}{{{match_subject}}}{{else}}{{subject}}{{/if}}</span>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{{else}}
|
{{else}}
|
||||||
@@ -84,7 +84,7 @@
|
|||||||
<span class="message_time">{{{timestr}}}</span>
|
<span class="message_time">{{{timestr}}}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="message_content">{{{content}}}</div>
|
<div class="message_content">{{#if ../../use_match_properties}}{{{match_content}}}{{else}}{{{content}}}{{/if}}</div>
|
||||||
<div class="message_expander message_length_controller" title="See the rest of this message">[More...]</div>
|
<div class="message_expander message_length_controller" title="See the rest of this message">[More...]</div>
|
||||||
<div class="message_collapser message_length_controller" title="Make this message take up less space on the screen">[Collapse this message]</div>
|
<div class="message_collapser message_length_controller" title="Make this message take up less space on the screen">[Collapse this message]</div>
|
||||||
</td>
|
</td>
|
||||||
|
|||||||
Reference in New Issue
Block a user