mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-04 05:53:43 +00:00 
			
		
		
		
	Use Dict everywhere we have keys based on potentially dangerous, user-supplied data
There are also one or two places we don't need to use it for security purposes, but we do so for consistencey. (imported from commit aa111f5a22a0e8597ec3cf8504adae66d5fb6768)
This commit is contained in:
		@@ -41,11 +41,11 @@ function sort_users(users, user_info) {
 | 
				
			|||||||
        // Sort equivalent PM names alphabetically
 | 
					        // Sort equivalent PM names alphabetically
 | 
				
			||||||
        var full_name_a = a;
 | 
					        var full_name_a = a;
 | 
				
			||||||
        var full_name_b = b;
 | 
					        var full_name_b = b;
 | 
				
			||||||
        if (people_dict[a] !== undefined) {
 | 
					        if (people_dict.has(a)) {
 | 
				
			||||||
            full_name_a = people_dict[a].full_name;
 | 
					            full_name_a = people_dict.get(a).full_name;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        if (people_dict[b] !== undefined) {
 | 
					        if (people_dict.has(b)) {
 | 
				
			||||||
            full_name_b = people_dict[b].full_name;
 | 
					            full_name_b = people_dict.get(b).full_name;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        return util.strcmp(full_name_a, full_name_b);
 | 
					        return util.strcmp(full_name_a, full_name_b);
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -203,8 +203,8 @@ exports.initialize = function () {
 | 
				
			|||||||
    $( "#subject" ).typeahead({
 | 
					    $( "#subject" ).typeahead({
 | 
				
			||||||
        source: function (query, process) {
 | 
					        source: function (query, process) {
 | 
				
			||||||
            var stream_name = $("#stream").val(), i;
 | 
					            var stream_name = $("#stream").val(), i;
 | 
				
			||||||
            if (subject_dict.hasOwnProperty(stream_name)) {
 | 
					            if (subject_dict.has(stream_name)) {
 | 
				
			||||||
                return subject_dict[stream_name];
 | 
					                return subject_dict.get(stream_name);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            return [];
 | 
					            return [];
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -33,7 +33,7 @@ function unmunge(k) {
 | 
				
			|||||||
    return k.substr(1);
 | 
					    return k.substr(1);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Dict.prototype = {
 | 
					Dict.prototype = _.object(_.map({
 | 
				
			||||||
    get: function Dict_get(key) {
 | 
					    get: function Dict_get(key) {
 | 
				
			||||||
        return this._items[munge(key)];
 | 
					        return this._items[munge(key)];
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
@@ -63,12 +63,9 @@ Dict.prototype = {
 | 
				
			|||||||
            return [unmunge(pair[0]), pair[1]];
 | 
					            return [unmunge(pair[0]), pair[1]];
 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
};
 | 
					}, function (value, key) {
 | 
				
			||||||
 | 
					    return [key, util.enforce_arity(value)];
 | 
				
			||||||
Dict.prototype = _.object(_.map(Dict.prototype,
 | 
					}));
 | 
				
			||||||
                                function (value, key) {
 | 
					 | 
				
			||||||
                                    return [key, util.enforce_arity(value)];
 | 
					 | 
				
			||||||
                                }));
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
}());
 | 
					}());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -291,15 +291,15 @@ exports.search_string = function () {
 | 
				
			|||||||
// Collect operators which appear only once into an object,
 | 
					// Collect operators which appear only once into an object,
 | 
				
			||||||
// and discard those which appear more than once.
 | 
					// and discard those which appear more than once.
 | 
				
			||||||
function collect_single(operators) {
 | 
					function collect_single(operators) {
 | 
				
			||||||
    var seen   = {};
 | 
					    var seen   = new Dict();
 | 
				
			||||||
    var result = {};
 | 
					    var result = new Dict();
 | 
				
			||||||
    _.each(operators, function (elem) {
 | 
					    _.each(operators, function (elem) {
 | 
				
			||||||
        var key = elem[0];
 | 
					        var key = elem[0];
 | 
				
			||||||
        if (seen.hasOwnProperty(key)) {
 | 
					        if (seen.has(key)) {
 | 
				
			||||||
            delete result[key];
 | 
					            result.del(key);
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            result[key] = elem[1];
 | 
					            result.set(key, elem[1]);
 | 
				
			||||||
            seen  [key] = true;
 | 
					            seen.set(key, true);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
    return result;
 | 
					    return result;
 | 
				
			||||||
@@ -317,16 +317,16 @@ exports.set_compose_defaults = function (opts) {
 | 
				
			|||||||
    // Set the stream, subject, and/or PM recipient if they are
 | 
					    // Set the stream, subject, and/or PM recipient if they are
 | 
				
			||||||
    // uniquely specified in the narrow view.
 | 
					    // uniquely specified in the narrow view.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (single.stream) {
 | 
					    if (single.has('stream')) {
 | 
				
			||||||
        opts.stream = single.stream;
 | 
					        opts.stream = single.get('stream');
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (single.topic) {
 | 
					    if (single.has('topic')) {
 | 
				
			||||||
        opts.subject = single.topic;
 | 
					        opts.subject = single.get('topic');
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (single['pm-with'] !== undefined) {
 | 
					    if (single.has('pm-with')) {
 | 
				
			||||||
        opts.private_message_recipient = single['pm-with'];
 | 
					        opts.private_message_recipient = single.get('pm-with');
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -281,7 +281,7 @@ function get_topic_suggestions(query_operators) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    stream = subs.canonicalized_name(stream);
 | 
					    stream = subs.canonicalized_name(stream);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    var topics = recent_subjects[stream];
 | 
					    var topics = recent_subjects.get(stream);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (!topics) {
 | 
					    if (!topics) {
 | 
				
			||||||
        return [];
 | 
					        return [];
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -16,11 +16,9 @@ exports.sort_narrow_list = function () {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    streams.sort(function (a, b) {
 | 
					    streams.sort(function (a, b) {
 | 
				
			||||||
        if (sort_recent) {
 | 
					        if (sort_recent) {
 | 
				
			||||||
            if (recent_subjects[b] !== undefined &&
 | 
					            if (recent_subjects.has(b) && ! recent_subjects.has(a)) {
 | 
				
			||||||
                recent_subjects[a] === undefined) {
 | 
					 | 
				
			||||||
                return 1;
 | 
					                return 1;
 | 
				
			||||||
            } else if (recent_subjects[b] === undefined &&
 | 
					            } else if (! recent_subjects.has(b) && recent_subjects.has(a)) {
 | 
				
			||||||
                       recent_subjects[a] !== undefined) {
 | 
					 | 
				
			||||||
                return -1;
 | 
					                return -1;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
@@ -41,7 +39,7 @@ exports.sort_narrow_list = function () {
 | 
				
			|||||||
    _.each(streams, function (stream) {
 | 
					    _.each(streams, function (stream) {
 | 
				
			||||||
        var li = $(subs.get(stream).sidebar_li);
 | 
					        var li = $(subs.get(stream).sidebar_li);
 | 
				
			||||||
        if (sort_recent) {
 | 
					        if (sort_recent) {
 | 
				
			||||||
            if (recent_subjects[stream] === undefined) {
 | 
					            if (! recent_subjects.has(stream)) {
 | 
				
			||||||
                li.addClass('inactive_stream');
 | 
					                li.addClass('inactive_stream');
 | 
				
			||||||
            } else {
 | 
					            } else {
 | 
				
			||||||
                li.removeClass('inactive_stream');
 | 
					                li.removeClass('inactive_stream');
 | 
				
			||||||
@@ -152,7 +150,7 @@ function rebuild_recent_subjects(stream, subject) {
 | 
				
			|||||||
    $('.expanded_subjects').remove();
 | 
					    $('.expanded_subjects').remove();
 | 
				
			||||||
    var max_subjects = 5;
 | 
					    var max_subjects = 5;
 | 
				
			||||||
    var stream_li = get_filter_li('stream', stream);
 | 
					    var stream_li = get_filter_li('stream', stream);
 | 
				
			||||||
    var subjects = recent_subjects[stream] || [];
 | 
					    var subjects = recent_subjects.get(stream) || [];
 | 
				
			||||||
    var active_orig_subject = subject;
 | 
					    var active_orig_subject = subject;
 | 
				
			||||||
    var display_subjects = _.filter(subjects, function (subject_obj, idx) {
 | 
					    var display_subjects = _.filter(subjects, function (subject_obj, idx) {
 | 
				
			||||||
        var num_unread = unread.num_unread_for_subject(stream, subject_obj.canon_subject);
 | 
					        var num_unread = unread.num_unread_for_subject(stream, subject_obj.canon_subject);
 | 
				
			||||||
@@ -230,19 +228,27 @@ exports.update_dom_with_unread_counts = function (counts) {
 | 
				
			|||||||
    // Our job is to update some DOM elements.
 | 
					    // Our job is to update some DOM elements.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // counts.stream_count maps streams to counts
 | 
					    // counts.stream_count maps streams to counts
 | 
				
			||||||
    _.each(counts.stream_count, function (count, stream) {
 | 
					    _.each(counts.stream_count.items(), function (item) {
 | 
				
			||||||
 | 
					        var stream = item[0];
 | 
				
			||||||
 | 
					        var count = item[1];
 | 
				
			||||||
        exports.set_count("stream", stream, count);
 | 
					        exports.set_count("stream", stream, count);
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // counts.subject_count maps streams to hashes of subjects to counts
 | 
					    // counts.subject_count maps streams to hashes of subjects to counts
 | 
				
			||||||
    _.each(counts.subject_count, function (subject_hash, stream) {
 | 
					    _.each(counts.subject_count.items(), function (item) {
 | 
				
			||||||
        _.each(subject_hash, function (count, subject) {
 | 
					        var stream = item[0];
 | 
				
			||||||
 | 
					        var subject_hash = item[1];
 | 
				
			||||||
 | 
					        _.each(subject_hash.items(), function (item) {
 | 
				
			||||||
 | 
					            var subject = item[0];
 | 
				
			||||||
 | 
					            var count = item[1];
 | 
				
			||||||
            exports.set_subject_count(stream, subject, count);
 | 
					            exports.set_subject_count(stream, subject, count);
 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // counts.pm_count maps people to counts
 | 
					    // counts.pm_count maps people to counts
 | 
				
			||||||
    _.each(counts.pm_count, function (count, person) {
 | 
					    _.each(counts.pm_count.items(), function (item) {
 | 
				
			||||||
 | 
					        var person = item[0];
 | 
				
			||||||
 | 
					        var count = item[1];
 | 
				
			||||||
        exports.set_count("private", person, count);
 | 
					        exports.set_count("private", person, count);
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -2,16 +2,16 @@ var subs = (function () {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
var exports = {};
 | 
					var exports = {};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
var stream_info = {}; // Maps lowercase stream name to stream properties object
 | 
					var stream_info = new Dict(); // Maps lowercase stream name to stream properties object
 | 
				
			||||||
 | 
					
 | 
				
			||||||
var next_sub_id = 0;
 | 
					var next_sub_id = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function add_sub(stream_name, sub) {
 | 
					function add_sub(stream_name, sub) {
 | 
				
			||||||
    stream_info[stream_name.toLowerCase()] = sub;
 | 
					    stream_info.set(stream_name.toLowerCase(), sub);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function get_sub(stream_name) {
 | 
					function get_sub(stream_name) {
 | 
				
			||||||
    return stream_info[stream_name.toLowerCase()];
 | 
					    return stream_info.get(stream_name.toLowerCase());
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
exports.stream_info = function (new_stream_info) {
 | 
					exports.stream_info = function (new_stream_info) {
 | 
				
			||||||
@@ -23,8 +23,7 @@ exports.stream_info = function (new_stream_info) {
 | 
				
			|||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
exports.subscribed_streams = function () {
 | 
					exports.subscribed_streams = function () {
 | 
				
			||||||
    return _.chain(stream_info)
 | 
					    return _.chain(stream_info.values())
 | 
				
			||||||
        .values()
 | 
					 | 
				
			||||||
        .where({subscribed: true})
 | 
					        .where({subscribed: true})
 | 
				
			||||||
        .pluck('name')
 | 
					        .pluck('name')
 | 
				
			||||||
        .value();
 | 
					        .value();
 | 
				
			||||||
@@ -43,7 +42,7 @@ exports.update_all_messages_link = function () {
 | 
				
			|||||||
    // the user has any subscriptions hidden from home view.
 | 
					    // the user has any subscriptions hidden from home view.
 | 
				
			||||||
    var all_messages = $("#global_filters [data-name='all']")[0];
 | 
					    var all_messages = $("#global_filters [data-name='all']")[0];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (_.every(stream_info, function (sub) { return sub.in_home_view; })) {
 | 
					    if (_.every(stream_info.values(), function (sub) { return sub.in_home_view; })) {
 | 
				
			||||||
        $(all_messages).addClass('hidden-filter');
 | 
					        $(all_messages).addClass('hidden-filter');
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
        $(all_messages).removeClass('hidden-filter');
 | 
					        $(all_messages).removeClass('hidden-filter');
 | 
				
			||||||
@@ -385,7 +384,7 @@ exports.reload_subscriptions = function (opts) {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (opts.clear_first) {
 | 
					    if (opts.clear_first) {
 | 
				
			||||||
        stream_info = {};
 | 
					        stream_info = new Dict();
 | 
				
			||||||
        stream_list.remove_all_narrow_filters();
 | 
					        stream_list.remove_all_narrow_filters();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -739,7 +738,7 @@ $(function () {
 | 
				
			|||||||
                        // mark_subscribed adds the user to the member list
 | 
					                        // mark_subscribed adds the user to the member list
 | 
				
			||||||
                        mark_subscribed(stream);
 | 
					                        mark_subscribed(stream);
 | 
				
			||||||
                    } else {
 | 
					                    } else {
 | 
				
			||||||
                        add_to_member_list(list, people_dict[principal].full_name, principal);
 | 
					                        add_to_member_list(list, people_dict.get(principal).full_name, principal);
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                } else {
 | 
					                } else {
 | 
				
			||||||
                    error_elem.addClass("hide");
 | 
					                    error_elem.addClass("hide");
 | 
				
			||||||
@@ -782,11 +781,11 @@ $(function () {
 | 
				
			|||||||
            success: function (data) {
 | 
					            success: function (data) {
 | 
				
			||||||
                util.destroy_loading_indicator(indicator_elem);
 | 
					                util.destroy_loading_indicator(indicator_elem);
 | 
				
			||||||
                var subscribers = _.map(data.subscribers, function (elem) {
 | 
					                var subscribers = _.map(data.subscribers, function (elem) {
 | 
				
			||||||
                    var person = people_dict[elem];
 | 
					                    var person = people_dict.get(elem);
 | 
				
			||||||
                    if (person === undefined) {
 | 
					                    if (person === undefined) {
 | 
				
			||||||
                        return elem;
 | 
					                        return elem;
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                    return format_member_list_elem(people_dict[elem].full_name, elem);
 | 
					                    return format_member_list_elem(people_dict.get(elem).full_name, elem);
 | 
				
			||||||
                });
 | 
					                });
 | 
				
			||||||
                _.each(subscribers.sort().reverse(), function (elem) {
 | 
					                _.each(subscribers.sort().reverse(), function (elem) {
 | 
				
			||||||
                    // add_to_member_list *prepends* the element,
 | 
					                    // add_to_member_list *prepends* the element,
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -41,10 +41,10 @@ function make_tab_data() {
 | 
				
			|||||||
            if (filter.has_operator("pm-with")) {
 | 
					            if (filter.has_operator("pm-with")) {
 | 
				
			||||||
                var emails = filter.operands("pm-with")[0].split(',');
 | 
					                var emails = filter.operands("pm-with")[0].split(',');
 | 
				
			||||||
                var names = _.map(emails, function (email) {
 | 
					                var names = _.map(emails, function (email) {
 | 
				
			||||||
                    if (! people_dict[email]) {
 | 
					                    if (! people_dict.has(email)) {
 | 
				
			||||||
                        return email;
 | 
					                        return email;
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                    return people_dict[email].full_name;
 | 
					                    return people_dict.get(email).full_name;
 | 
				
			||||||
                });
 | 
					                });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                tabs.push(make_tab(names.join(', '), hashed));
 | 
					                tabs.push(make_tab(names.join(', '), hashed));
 | 
				
			||||||
@@ -60,8 +60,8 @@ function make_tab_data() {
 | 
				
			|||||||
            tabs.push(make_tab("Mentions", hashed));
 | 
					            tabs.push(make_tab("Mentions", hashed));
 | 
				
			||||||
        } else if (filter.has_operator("sender")) {
 | 
					        } else if (filter.has_operator("sender")) {
 | 
				
			||||||
            var sender = filter.operands("sender")[0];
 | 
					            var sender = filter.operands("sender")[0];
 | 
				
			||||||
            if (people_dict[sender]) {
 | 
					            if (people_dict.has(sender)) {
 | 
				
			||||||
                sender = people_dict[sender].full_name;
 | 
					                sender = people_dict.get(sender).full_name;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            tabs.push(make_tab("Sent by " + sender, hashed));
 | 
					            tabs.push(make_tab("Sent by " + sender, hashed));
 | 
				
			||||||
        }  else if (filter.has_operator("search")) {
 | 
					        }  else if (filter.has_operator("search")) {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -7,9 +7,9 @@ var event_handlers = {};
 | 
				
			|||||||
// We'll temporarily set stream colors for the streams we use in the demo
 | 
					// We'll temporarily set stream colors for the streams we use in the demo
 | 
				
			||||||
// tutorial messages.
 | 
					// tutorial messages.
 | 
				
			||||||
var real_stream_info;
 | 
					var real_stream_info;
 | 
				
			||||||
var tutorial_stream_info = {"design": {"color": "#76ce90"},
 | 
					var tutorial_stream_info = new Dict({"design": {"color": "#76ce90"},
 | 
				
			||||||
                            "social": {"color": "#fae589"},
 | 
					                                     "social": {"color": "#fae589"},
 | 
				
			||||||
                            "devel": {"color": "#a6c7e5"}};
 | 
					                                     "devel": {"color": "#a6c7e5"}});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Each message object contains the minimal information necessary for it to be
 | 
					// Each message object contains the minimal information necessary for it to be
 | 
				
			||||||
// processed by our system for adding messages to your feed.
 | 
					// processed by our system for adding messages to your feed.
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1434,7 +1434,7 @@ exports.set_presence_list = function (users, presence_info) {
 | 
				
			|||||||
    function info_for(email) {
 | 
					    function info_for(email) {
 | 
				
			||||||
        var presence = presence_info[email];
 | 
					        var presence = presence_info[email];
 | 
				
			||||||
        return {
 | 
					        return {
 | 
				
			||||||
            name: people_dict[email].full_name,
 | 
					            name: people_dict.get(email).full_name,
 | 
				
			||||||
            email: email,
 | 
					            email: email,
 | 
				
			||||||
            type: presence,
 | 
					            type: presence,
 | 
				
			||||||
            type_desc: presence_descriptions[presence]
 | 
					            type_desc: presence_descriptions[presence]
 | 
				
			||||||
@@ -1442,7 +1442,7 @@ exports.set_presence_list = function (users, presence_info) {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    var user_emails = _.filter(users, function (email) {
 | 
					    var user_emails = _.filter(users, function (email) {
 | 
				
			||||||
        return people_dict[email] !== undefined;
 | 
					        return people_dict.has(email);
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    var user_info = [my_info].concat(_.map(user_emails, info_for));
 | 
					    var user_info = [my_info].concat(_.map(user_emails, info_for));
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -3,11 +3,11 @@ var unread = (function () {
 | 
				
			|||||||
var exports = {};
 | 
					var exports = {};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
var unread_counts = {
 | 
					var unread_counts = {
 | 
				
			||||||
    'stream': {},
 | 
					    'stream': new Dict(),
 | 
				
			||||||
    'private': {}
 | 
					    'private': new Dict()
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
var unread_mentioned = {};
 | 
					var unread_mentioned = {};
 | 
				
			||||||
var unread_subjects = {};
 | 
					var unread_subjects = new Dict();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function unread_hashkey(message) {
 | 
					function unread_hashkey(message) {
 | 
				
			||||||
    var hashkey;
 | 
					    var hashkey;
 | 
				
			||||||
@@ -17,17 +17,17 @@ function unread_hashkey(message) {
 | 
				
			|||||||
        hashkey = message.reply_to;
 | 
					        hashkey = message.reply_to;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (unread_counts[message.type][hashkey] === undefined) {
 | 
					    if (! unread_counts[message.type].has(hashkey)) {
 | 
				
			||||||
        unread_counts[message.type][hashkey] = {};
 | 
					        unread_counts[message.type].set(hashkey, {});
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (message.type === 'stream') {
 | 
					    if (message.type === 'stream') {
 | 
				
			||||||
        var canon_subject = subs.canonicalized_name(message.subject);
 | 
					        var canon_subject = subs.canonicalized_name(message.subject);
 | 
				
			||||||
        if (unread_subjects[hashkey] === undefined) {
 | 
					        if (! unread_subjects.has(hashkey)) {
 | 
				
			||||||
            unread_subjects[hashkey] = {};
 | 
					            unread_subjects.set(hashkey, new Dict());
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        if (unread_subjects[hashkey][canon_subject] === undefined) {
 | 
					        if (! unread_subjects.get(hashkey).has(canon_subject)) {
 | 
				
			||||||
            unread_subjects[hashkey][canon_subject] = {};
 | 
					            unread_subjects.get(hashkey).set(canon_subject, {});
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -47,19 +47,19 @@ exports.update_unread_subjects = function (msg, event) {
 | 
				
			|||||||
    var canon_subject = subs.canonicalized_name(msg.subject);
 | 
					    var canon_subject = subs.canonicalized_name(msg.subject);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (event.subject !== undefined &&
 | 
					    if (event.subject !== undefined &&
 | 
				
			||||||
        unread_subjects[canon_stream] !== undefined &&
 | 
					        unread_subjects.has(canon_stream) &&
 | 
				
			||||||
        unread_subjects[canon_stream][canon_subject] !== undefined &&
 | 
					        unread_subjects.get(canon_stream).has(canon_subject) &&
 | 
				
			||||||
        unread_subjects[canon_stream][canon_subject][msg.id]) {
 | 
					        unread_subjects.get(canon_stream).get(canon_subject)[msg.id]) {
 | 
				
			||||||
        var new_canon_subject = subs.canonicalized_name(event.subject);
 | 
					        var new_canon_subject = subs.canonicalized_name(event.subject);
 | 
				
			||||||
        // Move the unread subject count to the new subject
 | 
					        // Move the unread subject count to the new subject
 | 
				
			||||||
        delete unread_subjects[canon_stream][canon_subject][msg.id];
 | 
					        delete unread_subjects.get(canon_stream).get(canon_subject)[msg.id];
 | 
				
			||||||
        if (unread_subjects[canon_stream][canon_subject].length === 0) {
 | 
					        if (unread_subjects.get(canon_stream).get(canon_subject).length === 0) {
 | 
				
			||||||
            delete unread_subjects[canon_stream][canon_subject];
 | 
					            unread_subjects.get(canon_stream).del(canon_subject);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        if (unread_subjects[canon_stream][new_canon_subject] === undefined) {
 | 
					        if (! unread_subjects.get(canon_stream).has(new_canon_subject)) {
 | 
				
			||||||
            unread_subjects[canon_stream][new_canon_subject] = {};
 | 
					            unread_subjects.get(canon_stream).set(new_canon_subject, {});
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        unread_subjects[canon_stream][new_canon_subject][msg.id] = true;
 | 
					        unread_subjects.get(canon_stream).get(new_canon_subject)[msg.id] = true;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -71,11 +71,11 @@ exports.process_loaded_messages = function (messages) {
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        var hashkey = unread_hashkey(message);
 | 
					        var hashkey = unread_hashkey(message);
 | 
				
			||||||
        unread_counts[message.type][hashkey][message.id] = true;
 | 
					        unread_counts[message.type].get(hashkey)[message.id] = true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (message.type === 'stream') {
 | 
					        if (message.type === 'stream') {
 | 
				
			||||||
            var canon_subject = subs.canonicalized_name(message.subject);
 | 
					            var canon_subject = subs.canonicalized_name(message.subject);
 | 
				
			||||||
            unread_subjects[hashkey][canon_subject][message.id] = true;
 | 
					            unread_subjects.get(hashkey).get(canon_subject)[message.id] = true;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (message.mentioned) {
 | 
					        if (message.mentioned) {
 | 
				
			||||||
@@ -86,17 +86,17 @@ exports.process_loaded_messages = function (messages) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
exports.process_read_message = function (message) {
 | 
					exports.process_read_message = function (message) {
 | 
				
			||||||
    var hashkey = unread_hashkey(message);
 | 
					    var hashkey = unread_hashkey(message);
 | 
				
			||||||
    delete unread_counts[message.type][hashkey][message.id];
 | 
					    delete unread_counts[message.type].get(hashkey)[message.id];
 | 
				
			||||||
    if (message.type === 'stream') {
 | 
					    if (message.type === 'stream') {
 | 
				
			||||||
        var canon_stream = subs.canonicalized_name(message.stream);
 | 
					        var canon_stream = subs.canonicalized_name(message.stream);
 | 
				
			||||||
        var canon_subject = subs.canonicalized_name(message.subject);
 | 
					        var canon_subject = subs.canonicalized_name(message.subject);
 | 
				
			||||||
        delete unread_subjects[canon_stream][canon_subject][message.id];
 | 
					        delete unread_subjects.get(canon_stream).get(canon_subject)[message.id];
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    delete unread_mentioned[message.id];
 | 
					    delete unread_mentioned[message.id];
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
exports.declare_bankruptcy = function () {
 | 
					exports.declare_bankruptcy = function () {
 | 
				
			||||||
    unread_counts = {'stream': {}, 'private': {}};
 | 
					    unread_counts = {'stream': new Dict(), 'private': new Dict()};
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
exports.num_unread_current_messages = function () {
 | 
					exports.num_unread_current_messages = function () {
 | 
				
			||||||
@@ -120,9 +120,9 @@ exports.get_counts = function () {
 | 
				
			|||||||
    res.private_message_count = 0;
 | 
					    res.private_message_count = 0;
 | 
				
			||||||
    res.home_unread_messages = 0;
 | 
					    res.home_unread_messages = 0;
 | 
				
			||||||
    res.mentioned_message_count = Object.keys(unread_mentioned).length;
 | 
					    res.mentioned_message_count = Object.keys(unread_mentioned).length;
 | 
				
			||||||
    res.stream_count = {};  // hash by stream -> count
 | 
					    res.stream_count = new Dict();  // hash by stream -> count
 | 
				
			||||||
    res.subject_count = {}; // hash of hashes (stream, then subject -> count)
 | 
					    res.subject_count = new Dict(); // hash of hashes (stream, then subject -> count)
 | 
				
			||||||
    res.pm_count = {}; // Hash by email -> count
 | 
					    res.pm_count = new Dict(); // Hash by email -> count
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    function only_in_home_view(msgids) {
 | 
					    function only_in_home_view(msgids) {
 | 
				
			||||||
        return _.filter(msgids, function (msgid) {
 | 
					        return _.filter(msgids, function (msgid) {
 | 
				
			||||||
@@ -130,31 +130,37 @@ exports.get_counts = function () {
 | 
				
			|||||||
        });
 | 
					        });
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    _.each(unread_counts.stream, function (msgs, stream) {
 | 
					    _.each(unread_counts.stream.items(), function (item) {
 | 
				
			||||||
 | 
					        var stream = item[0];
 | 
				
			||||||
 | 
					        var msgs = item[1];
 | 
				
			||||||
        if (! subs.is_subscribed(stream)) {
 | 
					        if (! subs.is_subscribed(stream)) {
 | 
				
			||||||
            return true;
 | 
					            return true;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        var count = Object.keys(msgs).length;
 | 
					        var count = Object.keys(msgs).length;
 | 
				
			||||||
        res.stream_count[stream] = count;
 | 
					        res.stream_count.set(stream, count);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (subs.in_home_view(stream)) {
 | 
					        if (subs.in_home_view(stream)) {
 | 
				
			||||||
            res.home_unread_messages += only_in_home_view(Object.keys(msgs)).length;
 | 
					            res.home_unread_messages += only_in_home_view(Object.keys(msgs)).length;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (unread_subjects[stream] !== undefined) {
 | 
					        if (unread_subjects.has(stream)) {
 | 
				
			||||||
            res.subject_count[stream] = {};
 | 
					            res.subject_count.set(stream, new Dict());
 | 
				
			||||||
            _.each(unread_subjects[stream], function (msgs, subject) {
 | 
					            _.each(unread_subjects.get(stream).items(), function (item) {
 | 
				
			||||||
                res.subject_count[stream][subject] = Object.keys(msgs).length;
 | 
					                var subject = item[0];
 | 
				
			||||||
 | 
					                var msgs = item[1];
 | 
				
			||||||
 | 
					                res.subject_count.get(stream).set(subject, Object.keys(msgs).length);
 | 
				
			||||||
            });
 | 
					            });
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    var pm_count = 0;
 | 
					    var pm_count = 0;
 | 
				
			||||||
    _.each(unread_counts["private"], function (obj, index) {
 | 
					    _.each(unread_counts["private"].items(), function (item) {
 | 
				
			||||||
 | 
					        var index = item[0];
 | 
				
			||||||
 | 
					        var obj = item[1];
 | 
				
			||||||
        var count = Object.keys(obj).length;
 | 
					        var count = Object.keys(obj).length;
 | 
				
			||||||
        res.pm_count[index] = count;
 | 
					        res.pm_count.set(index, count);
 | 
				
			||||||
        pm_count += count;
 | 
					        pm_count += count;
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
    res.private_message_count = pm_count;
 | 
					    res.private_message_count = pm_count;
 | 
				
			||||||
@@ -172,9 +178,9 @@ exports.get_counts = function () {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
exports.num_unread_for_subject = function (stream, subject) {
 | 
					exports.num_unread_for_subject = function (stream, subject) {
 | 
				
			||||||
    var num_unread = 0;
 | 
					    var num_unread = 0;
 | 
				
			||||||
    if (unread_subjects[stream] !== undefined &&
 | 
					    if (unread_subjects.has(stream) &&
 | 
				
			||||||
        unread_subjects[stream][subject] !== undefined) {
 | 
					        unread_subjects.get(stream).has(subject)) {
 | 
				
			||||||
        num_unread = Object.keys(unread_subjects[stream][subject]).length;
 | 
					        num_unread = Object.keys(unread_subjects.get(stream).get(subject)).length;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    return num_unread;
 | 
					    return num_unread;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -5,9 +5,9 @@ var home_msg_list = new MessageList('zhome',
 | 
				
			|||||||
);
 | 
					);
 | 
				
			||||||
var narrowed_msg_list;
 | 
					var narrowed_msg_list;
 | 
				
			||||||
var current_msg_list = home_msg_list;
 | 
					var current_msg_list = home_msg_list;
 | 
				
			||||||
var subject_dict = {};
 | 
					var subject_dict = new Dict();
 | 
				
			||||||
var people_dict = {};
 | 
					var people_dict = new Dict();
 | 
				
			||||||
var recent_subjects = {};
 | 
					var recent_subjects = new Dict();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
var queued_mark_as_read = [];
 | 
					var queued_mark_as_read = [];
 | 
				
			||||||
var queued_flag_timer;
 | 
					var queued_flag_timer;
 | 
				
			||||||
@@ -43,7 +43,7 @@ var waiting_on_browser_scroll = true;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
function add_person(person) {
 | 
					function add_person(person) {
 | 
				
			||||||
    page_params.people_list.push(person);
 | 
					    page_params.people_list.push(person);
 | 
				
			||||||
    people_dict[person.email] = person;
 | 
					    people_dict.set(person.email, person);
 | 
				
			||||||
    person.pm_recipient_count = 0;
 | 
					    person.pm_recipient_count = 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -55,7 +55,7 @@ function remove_person(person) {
 | 
				
			|||||||
            break;
 | 
					            break;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    delete people_dict[person.email];
 | 
					    people_dict.del(person.email);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function update_person(person) {
 | 
					function update_person(person) {
 | 
				
			||||||
@@ -64,12 +64,12 @@ function update_person(person) {
 | 
				
			|||||||
    // that can change, this will need to either get complicated or be
 | 
					    // that can change, this will need to either get complicated or be
 | 
				
			||||||
    // replaced by MVC
 | 
					    // replaced by MVC
 | 
				
			||||||
    var i;
 | 
					    var i;
 | 
				
			||||||
    if (people_dict[person.email] === undefined) {
 | 
					    if (! people_dict.has(person.email)) {
 | 
				
			||||||
        blueslip.error("Got update_person event for unexpected user",
 | 
					        blueslip.error("Got update_person event for unexpected user",
 | 
				
			||||||
                       {email: person.email});
 | 
					                       {email: person.email});
 | 
				
			||||||
        return;
 | 
					        return;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    people_dict[person.email].full_name = person.full_name;
 | 
					    people_dict.get(person.email).full_name = person.full_name;
 | 
				
			||||||
    for (i = 0; i < page_params.people_list.length; i++) {
 | 
					    for (i = 0; i < page_params.people_list.length; i++) {
 | 
				
			||||||
        if (page_params.people_list[i].email === person.email) {
 | 
					        if (page_params.people_list[i].email === person.email) {
 | 
				
			||||||
            page_params.people_list[i].full_name = person.full_name;
 | 
					            page_params.people_list[i].full_name = person.full_name;
 | 
				
			||||||
@@ -503,22 +503,22 @@ function process_message_for_recent_subjects(message, remove_message) {
 | 
				
			|||||||
    var canon_stream = subs.canonicalized_name(message.stream);
 | 
					    var canon_stream = subs.canonicalized_name(message.stream);
 | 
				
			||||||
    var canon_subject = subs.canonicalized_name(message.subject);
 | 
					    var canon_subject = subs.canonicalized_name(message.subject);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (! recent_subjects.hasOwnProperty(canon_stream)) {
 | 
					    if (! recent_subjects.has(canon_stream)) {
 | 
				
			||||||
        recent_subjects[canon_stream] = [];
 | 
					        recent_subjects.set(canon_stream, []);
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
        recent_subjects[canon_stream] =
 | 
					        recent_subjects.set(canon_stream,
 | 
				
			||||||
            _.filter(recent_subjects[canon_stream], function (item) {
 | 
					                            _.filter(recent_subjects.get(canon_stream), function (item) {
 | 
				
			||||||
                var is_duplicate = (item.canon_subject.toLowerCase() === canon_subject.toLowerCase());
 | 
					                                var is_duplicate = (item.canon_subject.toLowerCase() === canon_subject.toLowerCase());
 | 
				
			||||||
                if (is_duplicate) {
 | 
					                                if (is_duplicate) {
 | 
				
			||||||
                    current_timestamp = item.timestamp;
 | 
					                                    current_timestamp = item.timestamp;
 | 
				
			||||||
                    count = item.count;
 | 
					                                    count = item.count;
 | 
				
			||||||
                }
 | 
					                                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                return !is_duplicate;
 | 
					                                return !is_duplicate;
 | 
				
			||||||
            });
 | 
					                            }));
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    var recents = recent_subjects[canon_stream];
 | 
					    var recents = recent_subjects.get(canon_stream);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (remove_message !== undefined) {
 | 
					    if (remove_message !== undefined) {
 | 
				
			||||||
        count = count - 1;
 | 
					        count = count - 1;
 | 
				
			||||||
@@ -537,7 +537,7 @@ function process_message_for_recent_subjects(message, remove_message) {
 | 
				
			|||||||
        return b.timestamp - a.timestamp;
 | 
					        return b.timestamp - a.timestamp;
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    recent_subjects[canon_stream] = recents;
 | 
					    recent_subjects.set(canon_stream, recents);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
var msg_metadata_cache = {};
 | 
					var msg_metadata_cache = {};
 | 
				
			||||||
@@ -570,12 +570,12 @@ function add_message_metadata(message) {
 | 
				
			|||||||
    case 'stream':
 | 
					    case 'stream':
 | 
				
			||||||
        message.is_stream = true;
 | 
					        message.is_stream = true;
 | 
				
			||||||
        message.stream = message.display_recipient;
 | 
					        message.stream = message.display_recipient;
 | 
				
			||||||
        if (! _.has(subject_dict, message.stream)) {
 | 
					        if (! subject_dict.has(message.stream)) {
 | 
				
			||||||
            subject_dict[message.stream] = [];
 | 
					            subject_dict.set(message.stream, []);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        if (! case_insensitive_find(message.subject, subject_dict[message.stream])) {
 | 
					        if (! case_insensitive_find(message.subject, subject_dict.get(message.stream))) {
 | 
				
			||||||
            subject_dict[message.stream].push(message.subject);
 | 
					            subject_dict.get(message.stream).push(message.subject);
 | 
				
			||||||
            subject_dict[message.stream].sort();
 | 
					            subject_dict.get(message.stream).sort();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        message.reply_to = message.sender_email;
 | 
					        message.reply_to = message.sender_email;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -608,13 +608,13 @@ function add_message_metadata(message) {
 | 
				
			|||||||
    _.each(involved_people, function (person) {
 | 
					    _.each(involved_people, function (person) {
 | 
				
			||||||
        // Do the hasOwnProperty() call via the prototype to avoid problems
 | 
					        // Do the hasOwnProperty() call via the prototype to avoid problems
 | 
				
			||||||
        // with keys like "hasOwnProperty"
 | 
					        // with keys like "hasOwnProperty"
 | 
				
			||||||
        if (people_dict[person.email] === undefined) {
 | 
					        if (! people_dict.has(person.email)) {
 | 
				
			||||||
            add_person(person);
 | 
					            add_person(person);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (message.type === 'private' && message.sent_by_me) {
 | 
					        if (message.type === 'private' && message.sent_by_me) {
 | 
				
			||||||
            // Track the number of PMs we've sent to this person to improve autocomplete
 | 
					            // Track the number of PMs we've sent to this person to improve autocomplete
 | 
				
			||||||
            people_dict[person.email].pm_recipient_count += 1;
 | 
					            people_dict.get(person.email).pm_recipient_count += 1;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -1199,13 +1199,13 @@ function fast_forward_pointer() {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
function main() {
 | 
					function main() {
 | 
				
			||||||
    _.each(page_params.people_list, function (person) {
 | 
					    _.each(page_params.people_list, function (person) {
 | 
				
			||||||
        people_dict[person.email] = person;
 | 
					        people_dict.set(person.email, person);
 | 
				
			||||||
        person.pm_recipient_count = 0;
 | 
					        person.pm_recipient_count = 0;
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // The special account feedback@zulip.com is used for in-app
 | 
					    // The special account feedback@zulip.com is used for in-app
 | 
				
			||||||
    // feedback and should always show up as an autocomplete option.
 | 
					    // feedback and should always show up as an autocomplete option.
 | 
				
			||||||
    if (people_dict['feedback@zulip.com'] === undefined){
 | 
					    if (! people_dict.has('feedback@zulip.com')){
 | 
				
			||||||
        add_person({"email": "feedback@zulip.com",
 | 
					        add_person({"email": "feedback@zulip.com",
 | 
				
			||||||
                    "full_name": "Zulip Feedback Bot"});
 | 
					                    "full_name": "Zulip Feedback Bot"});
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -4,6 +4,7 @@ var assert = require('assert');
 | 
				
			|||||||
    global._ = require('third/underscore/underscore.js');
 | 
					    global._ = require('third/underscore/underscore.js');
 | 
				
			||||||
    global.activity = require('js/activity.js');
 | 
					    global.activity = require('js/activity.js');
 | 
				
			||||||
    global.util = require('js/util.js');
 | 
					    global.util = require('js/util.js');
 | 
				
			||||||
 | 
					    global.Dict = require('js/dict.js');
 | 
				
			||||||
}());
 | 
					}());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
var activity = global.activity;
 | 
					var activity = global.activity;
 | 
				
			||||||
@@ -18,11 +19,11 @@ var activity = global.activity;
 | 
				
			|||||||
    };
 | 
					    };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    global.people_dict = {
 | 
					    global.people_dict = new global.Dict({
 | 
				
			||||||
        'alice@zulip.com': 'Alice Smith',
 | 
					        'alice@zulip.com': 'Alice Smith',
 | 
				
			||||||
        'fred@zulip.com': 'Fred Flintstone',
 | 
					        'fred@zulip.com': 'Fred Flintstone',
 | 
				
			||||||
        'jill@zulip.com': 'Jill Hill'
 | 
					        'jill@zulip.com': 'Jill Hill'
 | 
				
			||||||
    };
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    activity._sort_users(users, user_info);
 | 
					    activity._sort_users(users, user_info);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -3,6 +3,8 @@ var assert = require('assert');
 | 
				
			|||||||
(function set_up_dependencies () {
 | 
					(function set_up_dependencies () {
 | 
				
			||||||
    global._ = require('third/underscore/underscore.js');
 | 
					    global._ = require('third/underscore/underscore.js');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    global.util = require('js/util.js');
 | 
				
			||||||
 | 
					    global.Dict = require('js/dict.js');
 | 
				
			||||||
    // An upcoming change is to put Filter in its own module, but
 | 
					    // An upcoming change is to put Filter in its own module, but
 | 
				
			||||||
    // for now it still lives in narrow.js.  (I'm waiting for a big
 | 
					    // for now it still lives in narrow.js.  (I'm waiting for a big
 | 
				
			||||||
    // commit from Zev to hit master first.  Once that happens,
 | 
					    // commit from Zev to hit master first.  Once that happens,
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -3,6 +3,7 @@ var assert = require('assert');
 | 
				
			|||||||
(function set_up_dependencies () {
 | 
					(function set_up_dependencies () {
 | 
				
			||||||
    global._ = require('third/underscore/underscore.js');
 | 
					    global._ = require('third/underscore/underscore.js');
 | 
				
			||||||
    global.util = require('js/util.js');
 | 
					    global.util = require('js/util.js');
 | 
				
			||||||
 | 
					    global.Dict = require('js/dict.js');
 | 
				
			||||||
    global.narrow = require('js/narrow.js');
 | 
					    global.narrow = require('js/narrow.js');
 | 
				
			||||||
    global.$ = function () {}; // for subs.js
 | 
					    global.$ = function () {}; // for subs.js
 | 
				
			||||||
    global.subs = require('js/subs.js');
 | 
					    global.subs = require('js/subs.js');
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -31,9 +31,9 @@ function set_up_dependencies() {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    global.typeahead_helper = require('js/typeahead_helper.js');
 | 
					    global.typeahead_helper = require('js/typeahead_helper.js');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    global.recent_subjects = {};
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    global.util = require('js/util.js');
 | 
					    global.util = require('js/util.js');
 | 
				
			||||||
 | 
					    global.Dict = require('js/dict.js');
 | 
				
			||||||
 | 
					    global.recent_subjects = new global.Dict();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return search;
 | 
					    return search;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -107,13 +107,13 @@ var search = set_up_dependencies();
 | 
				
			|||||||
        return 'office';
 | 
					        return 'office';
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    global.recent_subjects = {
 | 
					    global.recent_subjects = new global.Dict({
 | 
				
			||||||
        office: [
 | 
					        office: [
 | 
				
			||||||
            {subject: 'team'},
 | 
					            {subject: 'team'},
 | 
				
			||||||
            {subject: 'ignore'},
 | 
					            {subject: 'ignore'},
 | 
				
			||||||
            {subject: 'test'}
 | 
					            {subject: 'test'}
 | 
				
			||||||
        ]
 | 
					        ]
 | 
				
			||||||
    };
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    var suggestions = search.get_suggestions(query);
 | 
					    var suggestions = search.get_suggestions(query);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -144,7 +144,7 @@ var search = set_up_dependencies();
 | 
				
			|||||||
        return;
 | 
					        return;
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    global.recent_subjects = {};
 | 
					    global.recent_subjects = new global.Dict();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    var suggestions = search.get_suggestions(query);
 | 
					    var suggestions = search.get_suggestions(query);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -177,13 +177,13 @@ var search = set_up_dependencies();
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
    ];
 | 
					    ];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    global.recent_subjects = {
 | 
					    global.recent_subjects = new global.Dict({
 | 
				
			||||||
        office: [
 | 
					        office: [
 | 
				
			||||||
            {subject: 'team'},
 | 
					            {subject: 'team'},
 | 
				
			||||||
            {subject: 'ignore'},
 | 
					            {subject: 'ignore'},
 | 
				
			||||||
            {subject: 'test'}
 | 
					            {subject: 'test'}
 | 
				
			||||||
        ]
 | 
					        ]
 | 
				
			||||||
    };
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    var suggestions = search.get_suggestions(query);
 | 
					    var suggestions = search.get_suggestions(query);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -8,6 +8,9 @@
 | 
				
			|||||||
// dependencies (except _).
 | 
					// dependencies (except _).
 | 
				
			||||||
 | 
					
 | 
				
			||||||
global._ = require('third/underscore/underscore.js');
 | 
					global._ = require('third/underscore/underscore.js');
 | 
				
			||||||
 | 
					global.util = require('js/util.js');
 | 
				
			||||||
 | 
					global.Dict = require('js/dict.js');
 | 
				
			||||||
 | 
					var Dict = global.Dict;
 | 
				
			||||||
var unread = require('js/unread.js');
 | 
					var unread = require('js/unread.js');
 | 
				
			||||||
var assert = require('assert');
 | 
					var assert = require('assert');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -31,9 +34,9 @@ var zero_counts = {
 | 
				
			|||||||
    private_message_count: 0,
 | 
					    private_message_count: 0,
 | 
				
			||||||
    home_unread_messages: 0,
 | 
					    home_unread_messages: 0,
 | 
				
			||||||
    mentioned_message_count: 0,
 | 
					    mentioned_message_count: 0,
 | 
				
			||||||
    stream_count: {},
 | 
					    stream_count: new Dict(),
 | 
				
			||||||
    subject_count: {},
 | 
					    subject_count: new Dict(),
 | 
				
			||||||
    pm_count: {},
 | 
					    pm_count: new Dict(),
 | 
				
			||||||
    unread_in_current_view: 0
 | 
					    unread_in_current_view: 0
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user