Isolate/eliminate uses of "match_subject".

This commit is contained in:
Steve Howell 2018-11-15 15:59:41 +00:00 committed by Tim Abbott
parent 89c278d1e5
commit 55362263dd
7 changed files with 17 additions and 10 deletions

View File

@ -85,7 +85,7 @@ run_test('add_message_metadata', () => {
// access cached previous message, and test match subject/content
message = {
id: 2067,
match_subject: "subject foo",
match_subject: "topic foo",
match_content: "bar content",
};
message = message_store.add_message_metadata(message);
@ -93,7 +93,7 @@ run_test('add_message_metadata', () => {
assert.equal(message.reply_to, 'bob@example.com,cindy@example.com');
assert.equal(message.to_user_ids, '103,104');
assert.equal(message.display_reply_to, 'Bob, Cindy');
assert.equal(message.match_subject, 'subject foo');
assert.equal(util.get_match_topic(message), 'topic foo');
assert.equal(message.match_content, 'bar content');
message = {

View File

@ -917,7 +917,7 @@ run_test('message_group', () => {
show_date: '"<span class="timerender82">Jan&nbsp;07</span>"',
show_date_separator: true,
subject: 'two messages',
match_subject: '<span class="highlight">two</span> messages',
match_topic: '<span class="highlight">two</span> messages',
},
];

View File

@ -23,8 +23,7 @@ function maybe_add_narrowed_messages(messages, msg_list, messages_are_new) {
var elsewhere_messages = [];
_.each(messages, function (elem) {
if (data.messages.hasOwnProperty(elem.id)) {
elem.match_subject = data.messages[elem.id].match_subject;
elem.match_content = data.messages[elem.id].match_content;
util.set_match_data(elem, data.messages[elem.id]);
new_messages.push(elem);
} else {
elsewhere_messages.push(elem);

View File

@ -104,7 +104,7 @@ function populate_group_from_message_container(group, message_container) {
group.color_class = stream_color.get_color_class(group.background_color);
group.invite_only = stream_data.get_invite_only(message_container.msg.stream);
group.subject = message_container.msg.subject;
group.match_subject = message_container.msg.match_subject;
group.match_topic = util.get_match_topic(message_container.msg);
group.stream_url = message_container.stream_url;
group.topic_url = message_container.topic_url;
var sub = stream_data.get_sub(message_container.msg.stream);

View File

@ -110,9 +110,8 @@ exports.add_message_metadata = function (message) {
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;
if (util.get_match_topic(message) !== undefined) {
util.set_match_data(cached_msg, message);
}
return cached_msg;
}

View File

@ -282,6 +282,15 @@ exports.get_topic_links = function (obj) {
return obj.subject_links;
};
exports.set_match_data = function (target, source) {
target.match_subject = source.match_subject;
target.match_content = source.match_content;
};
exports.get_match_topic = function (obj) {
return obj.match_subject;
};
return exports;
}());

View File

@ -24,7 +24,7 @@
href="{{topic_url}}"
title="{{#tr this}}Narrow to stream &quot;__display_recipient__&quot;, topic &quot;__subject__&quot;{{/tr}}">
{{#if use_match_properties}}
{{{match_subject}}}
{{{match_topic}}}
{{else}}
{{subject}}
{{/if}}