subject -> topic: Sweep "message.subject" in frontend.

These were the last remaining files.  After this, only
util.js has a non-email-related use of "subject".
This commit is contained in:
Steve Howell 2018-12-23 15:01:30 +00:00 committed by Tim Abbott
parent 7e17b8a392
commit 1ad30c6858
12 changed files with 27 additions and 21 deletions

View File

@ -1,3 +1,4 @@
zrequire('util');
var rs = zrequire('recent_senders');
run_test('process_message_for_senders', () => {

View File

@ -1,4 +1,5 @@
zrequire('unread');
zrequire('util');
zrequire('topic_data');
set_global('channel', {});

View File

@ -128,14 +128,14 @@ exports.edit_locally = function edit_locally(message, raw_content, new_topic) {
if (new_topic !== undefined) {
topic_data.remove_message({
stream_id: message.stream_id,
topic_name: message.subject,
topic_name: util.get_message_topic(message),
});
util.set_message_topic(message, new_topic);
topic_data.add_message({
stream_id: message.stream_id,
topic_name: message.subject,
topic_name: util.get_message_topic(message),
message_id: message.id,
});
}

View File

@ -31,7 +31,7 @@ function zephyr_topic_name_match(message, operand) {
related_regexp = new RegExp(/^/.source + util.escape_regexp(base_topic) + /(\.d)*$/.source, 'i');
}
return related_regexp.test(message.subject);
return related_regexp.test(util.get_message_topic(message));
}
function message_in_home(message) {
@ -106,7 +106,7 @@ function message_matches_search_term(message, operator, operand) {
if (page_params.realm_is_zephyr_mirror_realm) {
return zephyr_topic_name_match(message, operand);
}
return message.subject.toLowerCase() === operand;
return util.get_message_topic(message).toLowerCase() === operand;
case 'sender':

View File

@ -111,7 +111,7 @@ exports.add_topic_links = function (message) {
util.set_topic_links(message, []);
return;
}
var topic = message.subject;
var topic = util.get_message_topic(message);
var links = [];
_.each(realm_filter_list, function (realm_filter) {
var pattern = realm_filter[0];

View File

@ -135,13 +135,15 @@ exports.save = function (row, from_topic_edited_only) {
var new_content = row.find(".message_edit_content").val();
var topic_changed = false;
var new_topic;
var old_topic = util.get_message_topic(message);
if (message.type === "stream") {
if (from_topic_edited_only) {
new_topic = row.find(".inline_topic_edit").val();
} else {
new_topic = row.find(".message_edit_topic").val();
}
topic_changed = new_topic !== message.subject && new_topic.trim() !== "";
topic_changed = new_topic !== old_topic && new_topic.trim() !== "";
}
// Editing a not-yet-acked message (because the original send attempt failed)
// just results in the in-memory message being changed
@ -264,7 +266,7 @@ function edit_message(row, raw_content) {
message_id: message.id,
is_editable: is_editable,
has_been_editable: editability !== editability_types.NO,
topic: message.subject,
topic: util.get_message_topic(message),
content: raw_content,
minutes_to_edit: Math.floor(page_params.realm_message_content_edit_limit_seconds / 60)}));
@ -370,7 +372,7 @@ function edit_message(row, raw_content) {
if (!is_editable) {
row.find(".message_edit_close").focus();
} else if (message.type === 'stream' && message.subject === compose.empty_topic_placeholder()) {
} else if (message.type === 'stream' && util.get_message_topic(message) === compose.empty_topic_placeholder()) {
message_edit_topic.val('');
message_edit_topic.focus();
} else if (editability === editability_types.TOPIC_ONLY) {
@ -390,7 +392,7 @@ function edit_message(row, raw_content) {
message_viewport.scrollTop(message_viewport.scrollTop() + scroll_by);
if (feature_flags.propagate_topic_edits && !message.locally_echoed) {
var original_topic = message.subject;
var original_topic = util.get_message_topic(message);
message_edit_topic.keyup(function () {
var new_topic = message_edit_topic.val();
message_edit_topic_propagate.toggle(new_topic !== original_topic && new_topic !== "");
@ -452,7 +454,7 @@ exports.start_topic_edit = function (recipient_row) {
form.keydown(_.partial(handle_edit_keydown, true));
var msg_id = rows.id_for_recipient_row(recipient_row);
var message = current_msg_list.get(msg_id);
var topic = message.subject;
var topic = util.get_message_topic(message);
if (topic === compose.empty_topic_placeholder()) {
topic = '';
}

View File

@ -166,7 +166,7 @@ MessageListData.prototype = {
unmuted_messages: function (messages) {
return _.reject(messages, function (message) {
return muting.is_topic_muted(message.stream_id, message.subject) &&
return muting.is_topic_muted(message.stream_id, util.get_message_topic(message)) &&
!message.mentioned;
});
},

View File

@ -135,7 +135,7 @@ exports.add_message_metadata = function (message) {
topic_data.add_message({
stream_id: message.stream_id,
topic_name: message.subject,
topic_name: util.get_message_topic(message),
message_id: message.id,
});

View File

@ -382,14 +382,15 @@ exports.toggle_actions_popover = function (element, id) {
use_edit_icon = false;
editability_menu_item = i18n.t("View source");
}
var topic = util.get_message_topic(message);
var can_mute_topic =
message.stream &&
message.subject &&
!muting.is_topic_muted(message.stream_id, message.subject);
topic &&
!muting.is_topic_muted(message.stream_id, topic);
var can_unmute_topic =
message.stream &&
message.subject &&
muting.is_topic_muted(message.stream_id, message.subject);
topic &&
muting.is_topic_muted(message.stream_id, topic);
var should_display_edit_history_option = _.any(message.edit_history, function (entry) {
return entry.prev_content !== undefined;
@ -409,7 +410,7 @@ exports.toggle_actions_popover = function (element, id) {
message_id: message.id,
historical: message.historical,
stream_id: message.stream_id,
topic: util.get_message_topic(message),
topic: topic,
use_edit_icon: use_edit_icon,
editability_menu_item: editability_menu_item,
can_mute_topic: can_mute_topic,

View File

@ -7,17 +7,18 @@ var stream_senders = new Dict(); // key is stream-id, value is Dict
exports.process_message_for_senders = function (message) {
var stream_id = message.stream_id.toString();
var topic = util.get_message_topic(message);
// Process most recent sender to topic
var topic_dict = topic_senders.get(stream_id) || new Dict({fold_case: true});
var sender_message_ids = topic_dict.get(message.subject) || new Dict();
var sender_message_ids = topic_dict.get(topic) || new Dict();
var old_message_id = sender_message_ids.get(message.sender_id);
if (old_message_id === undefined || old_message_id < message.id) {
sender_message_ids.set(message.sender_id, message.id);
}
topic_dict.set(message.subject, sender_message_ids);
topic_dict.set(topic, sender_message_ids);
topic_senders.set(stream_id, topic_dict);
// Process most recent sender to whole stream

View File

@ -112,7 +112,7 @@ exports.reply_message = function (opts) {
reply.type = 'stream';
reply.to = stream;
reply.content = content;
util.set_message_topic(reply, message.subject);
util.set_message_topic(reply, util.get_message_topic(message));
transmit.send_message(reply, success, error);
return;

View File

@ -482,7 +482,7 @@ exports.process_loaded_messages = function (messages) {
if (message.type === 'stream') {
exports.unread_topic_counter.add(
message.stream_id,
message.subject,
util.get_message_topic(message),
message.id
);
}