mirror of
https://github.com/zulip/zulip.git
synced 2026-07-12 21:04:41 +08:00
Store the recipient stream name in message.stream.
Previously we were using message.display_recipient everywhere, which is actually pretty confusing. (imported from commit a58471172e28c039af8e290362e54b6660543924)
This commit is contained in:
parent
6e00c9ca3d
commit
de5038f4d7
@ -143,7 +143,7 @@ function do_fade(reply_message, fade_type) {
|
||||
type: fade_type
|
||||
};
|
||||
if (fade_type === "stream") {
|
||||
faded_to.display_recipient = reply_message.display_recipient;
|
||||
faded_to.stream = reply_message.stream;
|
||||
faded_to.subject = reply_message.subject;
|
||||
} else {
|
||||
faded_to.reply_to = reply_message.reply_to;
|
||||
|
||||
@ -292,9 +292,9 @@ MessageList.prototype = {
|
||||
message.unsubscribed = false;
|
||||
if (message.include_bookend && message.historical !== prev.historical) {
|
||||
if (message.historical) {
|
||||
message.unsubscribed = message.display_recipient;
|
||||
message.unsubscribed = message.stream;
|
||||
} else {
|
||||
message.subscribed = message.display_recipient;
|
||||
message.subscribed = message.stream;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -316,9 +316,9 @@ MessageList.prototype = {
|
||||
}
|
||||
|
||||
if (message.is_stream) {
|
||||
message.background_color = subs.get_color(message.display_recipient);
|
||||
message.background_color = subs.get_color(message.stream);
|
||||
message.color_class = subs.get_color_class(message.background_color);
|
||||
message.invite_only = subs.get_invite_only(message.display_recipient);
|
||||
message.invite_only = subs.get_invite_only(message.stream);
|
||||
}
|
||||
|
||||
message.contains_mention = notifications.speaking_at_me(message);
|
||||
|
||||
@ -192,7 +192,7 @@ exports.message_in_home = function (message) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return exports.stream_in_home(message.display_recipient);
|
||||
return exports.stream_in_home(message.stream);
|
||||
};
|
||||
|
||||
// Build a filter function from a list of operators.
|
||||
@ -235,7 +235,7 @@ function build_filter(operators_mixed_case) {
|
||||
|
||||
case 'stream':
|
||||
if ((message.type !== 'stream') ||
|
||||
(message.display_recipient.toLowerCase() !== operand))
|
||||
(message.stream.toLowerCase() !== operand))
|
||||
return false;
|
||||
break;
|
||||
|
||||
@ -436,7 +436,7 @@ exports.by_subject = function (target_id) {
|
||||
return;
|
||||
}
|
||||
exports.activate([
|
||||
['stream', original.display_recipient],
|
||||
['stream', original.stream],
|
||||
['subject', original.subject]
|
||||
], { then_select_id: target_id });
|
||||
};
|
||||
@ -450,7 +450,7 @@ exports.by_recipient = function (target_id) {
|
||||
break;
|
||||
|
||||
case 'stream':
|
||||
exports.by('stream', message.display_recipient, { then_select_id: target_id });
|
||||
exports.by('stream', message.stream, { then_select_id: target_id });
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
@ -103,7 +103,7 @@ function process_desktop_notification(message) {
|
||||
other_recipients = other_recipients.replace(message.sender_full_name + ", ", "");
|
||||
} else {
|
||||
key = message.sender_full_name + " to " +
|
||||
message.display_recipient + " > " + message.subject;
|
||||
message.stream + " > " + message.subject;
|
||||
}
|
||||
|
||||
if (content.length > 150) {
|
||||
@ -138,7 +138,7 @@ function process_desktop_notification(message) {
|
||||
title += " (to you and " + other_recipients + ")";
|
||||
}
|
||||
if (message.type === "stream") {
|
||||
title += " (to " + message.display_recipient + " > " + message.subject + ")";
|
||||
title += " (to " + message.stream + " > " + message.subject + ")";
|
||||
}
|
||||
|
||||
notice_memory[key] = {
|
||||
@ -197,7 +197,7 @@ function should_show_notification(message) {
|
||||
(message.type === "private" ||
|
||||
exports.speaking_at_me(message) ||
|
||||
(message.type === "stream" &&
|
||||
subs.receives_notifications(message.display_recipient)));
|
||||
subs.receives_notifications(message.stream)));
|
||||
}
|
||||
|
||||
exports.received_messages = function (messages) {
|
||||
|
||||
@ -167,7 +167,7 @@ exports.lower_bound = function (array, arg1, arg2, arg3, arg4) {
|
||||
|
||||
exports.same_stream_and_subject = function util_same_stream_and_subject(a, b) {
|
||||
// Streams and subjects are case-insensitive.
|
||||
return ((a.display_recipient.toLowerCase() === b.display_recipient.toLowerCase()) &&
|
||||
return ((a.stream.toLowerCase() === b.stream.toLowerCase()) &&
|
||||
(a.subject.toLowerCase() === b.subject.toLowerCase()));
|
||||
};
|
||||
|
||||
|
||||
@ -181,7 +181,7 @@ function respond_to_message(reply_type) {
|
||||
var stream = '';
|
||||
var subject = '';
|
||||
if (message.type === "stream") {
|
||||
stream = message.display_recipient;
|
||||
stream = message.stream;
|
||||
subject = message.subject;
|
||||
}
|
||||
|
||||
@ -320,7 +320,7 @@ function mark_all_as_read(cont) {
|
||||
function unread_hashkey(message) {
|
||||
var hashkey;
|
||||
if (message.type === 'stream') {
|
||||
hashkey = message.display_recipient;
|
||||
hashkey = message.stream;
|
||||
} else {
|
||||
hashkey = message.display_reply_to;
|
||||
}
|
||||
@ -469,11 +469,11 @@ function process_message_for_recent_subjects(message) {
|
||||
var current_timestamp = 0;
|
||||
var max_subjects = 5;
|
||||
|
||||
if (! recent_subjects.hasOwnProperty(message.display_recipient)) {
|
||||
recent_subjects[message.display_recipient] = [];
|
||||
if (! recent_subjects.hasOwnProperty(message.stream)) {
|
||||
recent_subjects[message.stream] = [];
|
||||
} else {
|
||||
recent_subjects[message.display_recipient] =
|
||||
$.grep(recent_subjects[message.display_recipient], function (item) {
|
||||
recent_subjects[message.stream] =
|
||||
$.grep(recent_subjects[message.stream], function (item) {
|
||||
if (item.subject === message.subject) {
|
||||
current_timestamp = item.timestamp;
|
||||
}
|
||||
@ -482,7 +482,7 @@ function process_message_for_recent_subjects(message) {
|
||||
});
|
||||
}
|
||||
|
||||
var recents = recent_subjects[message.display_recipient];
|
||||
var recents = recent_subjects[message.stream];
|
||||
recents.push({subject: message.subject,
|
||||
timestamp: Math.max(message.timestamp, current_timestamp)});
|
||||
|
||||
@ -492,7 +492,7 @@ function process_message_for_recent_subjects(message) {
|
||||
|
||||
recents = recents.slice(0, max_subjects);
|
||||
|
||||
recent_subjects[message.display_recipient] = recents;
|
||||
recent_subjects[message.stream] = recents;
|
||||
update_recent_subjects();
|
||||
}
|
||||
|
||||
@ -512,12 +512,13 @@ function add_message_metadata(message, dummy) {
|
||||
switch (message.type) {
|
||||
case 'stream':
|
||||
message.is_stream = true;
|
||||
if (! subject_dict.hasOwnProperty(message.display_recipient)) {
|
||||
subject_dict[message.display_recipient] = [];
|
||||
message.stream = message.display_recipient;
|
||||
if (! subject_dict.hasOwnProperty(message.stream)) {
|
||||
subject_dict[message.stream] = [];
|
||||
}
|
||||
if (! case_insensitive_find(message.subject, subject_dict[message.display_recipient])) {
|
||||
subject_dict[message.display_recipient].push(message.subject);
|
||||
subject_dict[message.display_recipient].sort();
|
||||
if (! case_insensitive_find(message.subject, subject_dict[message.stream])) {
|
||||
subject_dict[message.stream].push(message.subject);
|
||||
subject_dict[message.stream].sort();
|
||||
// We don't need to update the autocomplete after this because
|
||||
// the subject box's source is a function
|
||||
}
|
||||
|
||||
@ -17,7 +17,7 @@
|
||||
<a class="respond_button">
|
||||
<i class="icon-share-alt"></i>
|
||||
{{#if message.is_stream}}
|
||||
Reply to this subject on stream <b>{{message.display_recipient}}</b>
|
||||
Reply to this subject on stream <b>{{message.stream}}</b>
|
||||
{{else}}
|
||||
Reply to this private message
|
||||
{{/if}}
|
||||
@ -35,7 +35,7 @@
|
||||
<li>
|
||||
<a class="popover_narrow_by_subject_button" data-msgid="{{message.id}}">
|
||||
<i class="icon-bullhorn"></i>
|
||||
Narrow to this subject on stream <b>{{message.display_recipient}}</b>
|
||||
Narrow to this subject on stream <b>{{message.stream}}</b>
|
||||
</a>
|
||||
</li>
|
||||
{{else}}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{{! Title of the "message actions" popup }}
|
||||
{{#if message.is_stream}}
|
||||
Message to stream <b>{{message.display_recipient}}</b>
|
||||
Message to stream <b>{{message.stream}}</b>
|
||||
{{else}}
|
||||
Private message
|
||||
{{/if}}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user