mirror of https://github.com/zulip/zulip.git
Use same canonicalization for stream names when calculating recent subjects
(imported from commit d934f67cb469728162b8ae48b5fc63805bf18d8f)
This commit is contained in:
parent
cce8dfab84
commit
c12fd08050
|
@ -65,7 +65,7 @@ Filter.prototype = {
|
|||
// We don't use $.map because it flattens returned arrays.
|
||||
$.each(operators_mixed_case, function (idx, operator) {
|
||||
// We may want to consider allowing mixed-case operators at some point
|
||||
new_operators.push([operator[0], operator[1].toString().toLowerCase()]);
|
||||
new_operators.push([operator[0], subs.canonicalized_name(operator[1])]);
|
||||
});
|
||||
return new_operators;
|
||||
},
|
||||
|
|
|
@ -118,6 +118,10 @@ exports.stream_id = function(stream_name) {
|
|||
return parseInt(sub.id, 10);
|
||||
};
|
||||
|
||||
exports.canonicalized_name = function (stream_name) {
|
||||
return stream_name.toString().toLowerCase();
|
||||
};
|
||||
|
||||
function update_stream_sidebar_swatch_color(stream_name, color) {
|
||||
var id = exports.stream_id(stream_name);
|
||||
$("#stream_sidebar_swatch_" + id).css('background-color', color);
|
||||
|
|
|
@ -443,13 +443,15 @@ function process_message_for_recent_subjects(message, remove_message) {
|
|||
var current_timestamp = 0;
|
||||
var max_subjects = 5;
|
||||
var count = 0;
|
||||
var canon_stream = subs.canonicalized_name(message.stream);
|
||||
var canon_subject = subs.canonicalized_name(message.subject);
|
||||
|
||||
if (! recent_subjects.hasOwnProperty(message.stream)) {
|
||||
recent_subjects[message.stream] = [];
|
||||
if (! recent_subjects.hasOwnProperty(canon_stream)) {
|
||||
recent_subjects[canon_stream] = [];
|
||||
} else {
|
||||
recent_subjects[message.stream] =
|
||||
$.grep(recent_subjects[message.stream], function (item) {
|
||||
var is_duplicate = (item.subject.toLowerCase() === message.subject.toLowerCase());
|
||||
recent_subjects[canon_stream] =
|
||||
$.grep(recent_subjects[canon_stream], function (item) {
|
||||
var is_duplicate = (item.canon_subject.toLowerCase() === canon_subject.toLowerCase());
|
||||
if (is_duplicate) {
|
||||
current_timestamp = item.timestamp;
|
||||
count = item.count;
|
||||
|
@ -459,7 +461,7 @@ function process_message_for_recent_subjects(message, remove_message) {
|
|||
});
|
||||
}
|
||||
|
||||
var recents = recent_subjects[message.stream];
|
||||
var recents = recent_subjects[canon_stream];
|
||||
|
||||
if (remove_message !== undefined) {
|
||||
count = count - 1;
|
||||
|
@ -469,6 +471,7 @@ function process_message_for_recent_subjects(message, remove_message) {
|
|||
|
||||
if (count !== 0) {
|
||||
recents.push({subject: message.subject,
|
||||
canon_subject: canon_subject,
|
||||
count: count,
|
||||
timestamp: Math.max(message.timestamp, current_timestamp)});
|
||||
}
|
||||
|
@ -479,7 +482,7 @@ function process_message_for_recent_subjects(message, remove_message) {
|
|||
|
||||
recents = recents.slice(0, max_subjects);
|
||||
|
||||
recent_subjects[message.stream] = recents;
|
||||
recent_subjects[canon_stream] = recents;
|
||||
}
|
||||
|
||||
var msg_metadata_cache = {};
|
||||
|
|
Loading…
Reference in New Issue