mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-04 05:53:43 +00:00 
			
		
		
		
	Replace $.map with _.map
(imported from commit 97c7a6612d8d56d19f8650db0ea8906afc0f20ef)
This commit is contained in:
		@@ -92,14 +92,11 @@ Filter.prototype = {
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
    _canonicalize_operators: function Filter__canonicalize_operators(operators_mixed_case) {
 | 
			
		||||
        var new_operators = [];
 | 
			
		||||
        // We don't use $.map because it flattens returned arrays.
 | 
			
		||||
        $.each(operators_mixed_case, function (idx, operator) {
 | 
			
		||||
        return _.map(operators_mixed_case, function (operator) {
 | 
			
		||||
            // We may want to consider allowing mixed-case operators at some point
 | 
			
		||||
            new_operators.push([exports.canonicalize_operator(operator[0]),
 | 
			
		||||
                                subs.canonicalized_name(operator[1])]);
 | 
			
		||||
            return [exports.canonicalize_operator(operator[0]),
 | 
			
		||||
                    subs.canonicalized_name(operator[1])];
 | 
			
		||||
        });
 | 
			
		||||
        return new_operators;
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
    // Build a filter function from a list of operators.
 | 
			
		||||
 
 | 
			
		||||
@@ -52,7 +52,7 @@ function describe(operators) {
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    var more_parts = $.map(operators, function (elem) {
 | 
			
		||||
    var more_parts = _.map(operators, function (elem) {
 | 
			
		||||
        var operand = elem[1];
 | 
			
		||||
        switch (narrow.canonicalize_operator(elem[0])) {
 | 
			
		||||
        case 'is':
 | 
			
		||||
@@ -154,7 +154,7 @@ function get_stream_suggestions(operators) {
 | 
			
		||||
 | 
			
		||||
    streams = typeahead_helper.sorter(query, streams);
 | 
			
		||||
 | 
			
		||||
    var objs = $.map(streams, function (stream) {
 | 
			
		||||
    var objs = _.map(streams, function (stream) {
 | 
			
		||||
        var prefix = 'Narrow to stream';
 | 
			
		||||
        var highlighted_stream = typeahead_helper.highlight_query_in_phrase(query, stream);
 | 
			
		||||
        var description = prefix + ' ' + highlighted_stream;
 | 
			
		||||
@@ -209,7 +209,7 @@ function get_private_suggestions(all_people, operators) {
 | 
			
		||||
    // Take top 15 people, since they're ordered by pm_recipient_count.
 | 
			
		||||
    people = people.slice(0, 15);
 | 
			
		||||
 | 
			
		||||
    var suggestions = $.map(people, function (person) {
 | 
			
		||||
    var suggestions = _.map(people, function (person) {
 | 
			
		||||
        var name = highlight_person(query, person);
 | 
			
		||||
        var description = 'Narrow to private messages with ' + name;
 | 
			
		||||
        var search_string = narrow.unparse([['pm-with', person.email]]);
 | 
			
		||||
@@ -235,7 +235,7 @@ function get_person_suggestions(all_people, query, prefix, operator) {
 | 
			
		||||
 | 
			
		||||
    people.sort(typeahead_helper.compare_by_pms);
 | 
			
		||||
 | 
			
		||||
    var objs = $.map(people, function (person) {
 | 
			
		||||
    var objs = _.map(people, function (person) {
 | 
			
		||||
        var name = highlight_person(query, person);
 | 
			
		||||
        var description = prefix + ' ' + name;
 | 
			
		||||
        var search_string = operator + ':' + person.email;
 | 
			
		||||
@@ -323,8 +323,7 @@ function get_topic_suggestions(query_operators) {
 | 
			
		||||
    // still slice off enough topics to find matches.
 | 
			
		||||
    topics = topics.slice(0, 100);
 | 
			
		||||
 | 
			
		||||
    // topics = $.map(topics, (t) -> t.subject)
 | 
			
		||||
    topics = $.map(topics, function (topic) {
 | 
			
		||||
    topics = _.map(topics, function (topic) {
 | 
			
		||||
        return topic.subject; // "subject" is just the name of the topic
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
@@ -342,7 +341,7 @@ function get_topic_suggestions(query_operators) {
 | 
			
		||||
    // care about case.
 | 
			
		||||
    topics.sort();
 | 
			
		||||
 | 
			
		||||
    return $.map(topics, function (topic) {
 | 
			
		||||
    return _.map(topics, function (topic) {
 | 
			
		||||
        var topic_operator = ['topic', topic];
 | 
			
		||||
        var operators = query_operators.concat([topic_operator]);
 | 
			
		||||
        var search_string = narrow.unparse(operators);
 | 
			
		||||
@@ -468,7 +467,7 @@ exports.get_suggestions = function (query) {
 | 
			
		||||
            final_result.push(obj);
 | 
			
		||||
        }
 | 
			
		||||
    });
 | 
			
		||||
    return $.map(final_result, function (obj) {
 | 
			
		||||
    return _.map(final_result, function (obj) {
 | 
			
		||||
        return obj.search_string;
 | 
			
		||||
    });
 | 
			
		||||
};
 | 
			
		||||
 
 | 
			
		||||
@@ -956,7 +956,7 @@ $(function () {
 | 
			
		||||
            data: {stream: stream},
 | 
			
		||||
            success: function (data) {
 | 
			
		||||
                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];
 | 
			
		||||
                    if (person === undefined) {
 | 
			
		||||
                        return elem;
 | 
			
		||||
 
 | 
			
		||||
@@ -40,7 +40,7 @@ function make_tab_data() {
 | 
			
		||||
 | 
			
		||||
            if (filter.has_operator("pm-with")) {
 | 
			
		||||
                var emails = filter.operands("pm-with")[0].split(',');
 | 
			
		||||
                var names = $.map(emails, function (email) {
 | 
			
		||||
                var names = _.map(emails, function (email) {
 | 
			
		||||
                    if (! people_dict[email]) {
 | 
			
		||||
                        return email;
 | 
			
		||||
                    }
 | 
			
		||||
 
 | 
			
		||||
@@ -1374,7 +1374,7 @@ exports.set_presence_list = function (users, presence_info) {
 | 
			
		||||
        return people_dict[email] !== undefined;
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
    var user_info = [my_info].concat($.map(user_emails, info_for));
 | 
			
		||||
    var user_info = [my_info].concat(_.map(user_emails, info_for));
 | 
			
		||||
 | 
			
		||||
    $('#user_presences').html(templates.render('user_presence_rows', {users: user_info}));
 | 
			
		||||
};
 | 
			
		||||
 
 | 
			
		||||
@@ -218,7 +218,7 @@ exports.normalize_recipients = function (recipients) {
 | 
			
		||||
    // Converts a string listing emails of message recipients
 | 
			
		||||
    // into a canonical formatting: emails sorted ASCIIbetically
 | 
			
		||||
    // with exactly one comma and no spaces between each.
 | 
			
		||||
    recipients = $.map(recipients.split(','), $.trim);
 | 
			
		||||
    recipients = _.map(recipients.split(','), $.trim);
 | 
			
		||||
    recipients = _.filter(recipients, function (s) { return s.length > 0; });
 | 
			
		||||
    recipients.sort();
 | 
			
		||||
    return recipients.join(',');
 | 
			
		||||
 
 | 
			
		||||
@@ -535,7 +535,7 @@ function process_message_for_recent_subjects(message, remove_message) {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
var msg_metadata_cache = {};
 | 
			
		||||
function add_message_metadata(message, dummy) {
 | 
			
		||||
function add_message_metadata(message) {
 | 
			
		||||
    var cached_msg = msg_metadata_cache[message.id];
 | 
			
		||||
    if (cached_msg !== undefined) {
 | 
			
		||||
        // Copy the match subject and content over if they exist on
 | 
			
		||||
@@ -721,7 +721,7 @@ function maybe_add_narrowed_messages(messages, msg_list, messages_are_new) {
 | 
			
		||||
                }
 | 
			
		||||
            });
 | 
			
		||||
 | 
			
		||||
            new_messages = $.map(new_messages, add_message_metadata);
 | 
			
		||||
            new_messages = _.map(new_messages, add_message_metadata);
 | 
			
		||||
            add_messages(new_messages, msg_list, messages_are_new);
 | 
			
		||||
            process_visible_unread_messages();
 | 
			
		||||
            compose.update_faded_messages();
 | 
			
		||||
@@ -862,7 +862,7 @@ function get_updates_success(data) {
 | 
			
		||||
        // server update.  Once that bug is fixed, this
 | 
			
		||||
        // should no longer be needed
 | 
			
		||||
        messages = deduplicate_messages(messages);
 | 
			
		||||
        messages = $.map(messages, add_message_metadata);
 | 
			
		||||
        messages = _.map(messages, add_message_metadata);
 | 
			
		||||
 | 
			
		||||
        // You must add add messages to home_msg_list BEFORE
 | 
			
		||||
        // calling process_loaded_for_unread.
 | 
			
		||||
@@ -1024,7 +1024,7 @@ function load_old_messages(opts) {
 | 
			
		||||
            narrow.show_empty_narrow_message();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        messages = $.map(messages, add_message_metadata);
 | 
			
		||||
        messages = _.map(messages, add_message_metadata);
 | 
			
		||||
 | 
			
		||||
        // If we're loading more messages into the home view, save them to
 | 
			
		||||
        // the all_msg_list as well, as the home_msg_list is reconstructed
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user