mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-04 05:53:43 +00:00 
			
		
		
		
	list_render: Make list creation logic as an export in list_render module.
This changes how we create lists i.e.
    from `list_render($container, list, opts)`
        to `list_render.create($container, list, opts)`
			
			
This commit is contained in:
		@@ -142,7 +142,7 @@ run_test('list_render', () => {
 | 
			
		||||
        modifier: (item) => div(item),
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    const widget = list_render(container, list, opts);
 | 
			
		||||
    const widget = list_render.create(container, list, opts);
 | 
			
		||||
 | 
			
		||||
    widget.render();
 | 
			
		||||
 | 
			
		||||
@@ -265,7 +265,7 @@ run_test('sorting', () => {
 | 
			
		||||
        return _.map(people, opts.modifier).join('');
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    list_render(container, list, opts);
 | 
			
		||||
    list_render.create(container, list, opts);
 | 
			
		||||
    initialize();
 | 
			
		||||
 | 
			
		||||
    var button_opts;
 | 
			
		||||
 
 | 
			
		||||
@@ -39,7 +39,7 @@ function render_attachments_ui() {
 | 
			
		||||
    var uploaded_files_table = $("#uploaded_files_table").expectOne();
 | 
			
		||||
    var $search_input = $("#upload_file_search");
 | 
			
		||||
 | 
			
		||||
    var list = list_render(uploaded_files_table, attachments, {
 | 
			
		||||
    var list = list_render.create(uploaded_files_table, attachments, {
 | 
			
		||||
        name: "uploaded-files-list",
 | 
			
		||||
        modifier: function (attachment) {
 | 
			
		||||
            return templates.render("uploaded_files_list", { attachment: attachment });
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,9 @@
 | 
			
		||||
/* eslint indent: "off" */
 | 
			
		||||
 | 
			
		||||
var list_render = (function () {
 | 
			
		||||
 | 
			
		||||
    var exports = {};
 | 
			
		||||
 | 
			
		||||
    var DEFAULTS = {
 | 
			
		||||
        INITIAL_RENDER_COUNT: 80,
 | 
			
		||||
        LOAD_COUNT: 20,
 | 
			
		||||
@@ -11,7 +14,7 @@ var list_render = (function () {
 | 
			
		||||
    // container: jQuery object to append to.
 | 
			
		||||
    // list: The list of items to progressively append.
 | 
			
		||||
    // opts: An object of random preferences.
 | 
			
		||||
    var func = function ($container, list, opts) {
 | 
			
		||||
    exports.create = function ($container, list, opts) {
 | 
			
		||||
        // this memoizes the results and will return a previously invoked
 | 
			
		||||
        // instance's prototype.
 | 
			
		||||
        if (opts.name && DEFAULTS.instances[opts.name]) {
 | 
			
		||||
@@ -322,12 +325,12 @@ var list_render = (function () {
 | 
			
		||||
        return prototype;
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    func.get = function (name) {
 | 
			
		||||
    exports.get = function (name) {
 | 
			
		||||
        return DEFAULTS.instances[name] || false;
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    // this can delete list render issues and free up memory if needed.
 | 
			
		||||
    func.delete = function (name) {
 | 
			
		||||
    exports.delete = function (name) {
 | 
			
		||||
        if (DEFAULTS.instances[name]) {
 | 
			
		||||
            delete DEFAULTS.instances[name];
 | 
			
		||||
            return true;
 | 
			
		||||
@@ -338,7 +341,7 @@ var list_render = (function () {
 | 
			
		||||
        return false;
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    return func;
 | 
			
		||||
    return exports;
 | 
			
		||||
}());
 | 
			
		||||
 | 
			
		||||
if (typeof module !== 'undefined') {
 | 
			
		||||
 
 | 
			
		||||
@@ -28,7 +28,7 @@ function populate_invites(invites_data) {
 | 
			
		||||
        admin_invites_list.set_container(invites_table);
 | 
			
		||||
        admin_invites_list.render();
 | 
			
		||||
    } else {
 | 
			
		||||
        list_render(invites_table, invites_data.invites, {
 | 
			
		||||
        list_render.create(invites_table, invites_data.invites, {
 | 
			
		||||
            name: "admin_invites_list",
 | 
			
		||||
            modifier: function (item) {
 | 
			
		||||
                item.invited = timerender.absolute_time(item.invited * 1000);
 | 
			
		||||
 
 | 
			
		||||
@@ -348,7 +348,7 @@ exports.populate_notifications_stream_dropdown = function (stream_list) {
 | 
			
		||||
    var dropdown_list_body = $("#id_realm_notifications_stream .dropdown-list-body").expectOne();
 | 
			
		||||
    var search_input = $("#id_realm_notifications_stream .dropdown-search > input[type=text]");
 | 
			
		||||
 | 
			
		||||
    list_render(dropdown_list_body, stream_list, {
 | 
			
		||||
    list_render.create(dropdown_list_body, stream_list, {
 | 
			
		||||
        name: "admin-realm-notifications-stream-dropdown-list",
 | 
			
		||||
        modifier: function (item) {
 | 
			
		||||
            return templates.render("admin-realm-dropdown-stream-list", { stream: item });
 | 
			
		||||
@@ -379,7 +379,7 @@ exports.populate_signup_notifications_stream_dropdown = function (stream_list) {
 | 
			
		||||
    var dropdown_list_body = $("#id_realm_signup_notifications_stream .dropdown-list-body").expectOne();
 | 
			
		||||
    var search_input = $("#id_realm_signup_notifications_stream .dropdown-search > input[type=text]");
 | 
			
		||||
 | 
			
		||||
    list_render(dropdown_list_body, stream_list, {
 | 
			
		||||
    list_render.create(dropdown_list_body, stream_list, {
 | 
			
		||||
        name: "admin-realm-signup-notifications-stream-dropdown-list",
 | 
			
		||||
        modifier: function (item) {
 | 
			
		||||
            return templates.render("admin-realm-dropdown-stream-list", { stream: item });
 | 
			
		||||
 
 | 
			
		||||
@@ -17,7 +17,7 @@ exports.build_default_stream_table = function (streams_data) {
 | 
			
		||||
 | 
			
		||||
    var table = $("#admin_default_streams_table").expectOne();
 | 
			
		||||
 | 
			
		||||
    list_render(table, streams_data, {
 | 
			
		||||
    list_render.create(table, streams_data, {
 | 
			
		||||
        name: "default_streams_list",
 | 
			
		||||
        modifier: function (item) {
 | 
			
		||||
            var row = $(templates.render("admin_default_streams_list", { stream: item, can_modify: page_params.is_admin }));
 | 
			
		||||
 
 | 
			
		||||
@@ -112,7 +112,7 @@ function populate_users(realm_people_data) {
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    var $bots_table = $("#admin_bots_table");
 | 
			
		||||
    list_render($bots_table, bots, {
 | 
			
		||||
    list_render.create($bots_table, bots, {
 | 
			
		||||
        name: "admin_bot_list",
 | 
			
		||||
        modifier: function (item) {
 | 
			
		||||
            return templates.render("admin_user_list", { user: item, can_modify: page_params.is_admin });
 | 
			
		||||
@@ -130,7 +130,7 @@ function populate_users(realm_people_data) {
 | 
			
		||||
    }).init();
 | 
			
		||||
 | 
			
		||||
    var $users_table = $("#admin_users_table");
 | 
			
		||||
    list_render($users_table, active_users, {
 | 
			
		||||
    list_render.create($users_table, active_users, {
 | 
			
		||||
        name: "users_table_list",
 | 
			
		||||
        modifier: function (item) {
 | 
			
		||||
            var activity_rendered;
 | 
			
		||||
@@ -170,7 +170,7 @@ function populate_users(realm_people_data) {
 | 
			
		||||
    }).init();
 | 
			
		||||
 | 
			
		||||
    var $deactivated_users_table = $("#admin_deactivated_users_table");
 | 
			
		||||
    list_render($deactivated_users_table, deactivated_users, {
 | 
			
		||||
    list_render.create($deactivated_users_table, deactivated_users, {
 | 
			
		||||
        name: "deactivated_users_table_list",
 | 
			
		||||
        modifier: function (item) {
 | 
			
		||||
            return templates.render("admin_user_list", { user: item, can_modify: page_params.is_admin });
 | 
			
		||||
 
 | 
			
		||||
@@ -193,7 +193,7 @@ function show_subscription_settings(sub_row) {
 | 
			
		||||
    var emails = get_email_of_subscribers(sub.subscribers);
 | 
			
		||||
    exports.sort_but_pin_current_user_on_top(emails);
 | 
			
		||||
 | 
			
		||||
    list_render(list, emails, {
 | 
			
		||||
    list_render.create(list, emails, {
 | 
			
		||||
        name: "stream_subscribers/" + stream_id,
 | 
			
		||||
        modifier: function (item) {
 | 
			
		||||
            return format_member_list_elem(item);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user