list_render: Clean up initialization.

For some widgets we now avoid duplicate redraw
events from this old pattern:

    widget = list_render.create(..., {
    }).init();
    widget.sort(...);

The above code was wasteful and possibly
flicker-y due to the fact that `init` and
`sort` both render.

Now we do this:

    widget = list_render.create(..., {
        init_sort: [...],
    });

For other widgets we just clean up the need
to call `init()` right after `create()`.

We also allow widgets to pass in `sort_fields`
during initialization (since you may want to
have `init_sort` use a custom sort before the
first render.)
This commit is contained in:
Steve Howell
2020-04-11 14:23:29 +00:00
committed by Tim Abbott
parent ef749dba31
commit 0681e4ba36
12 changed files with 84 additions and 100 deletions

View File

@@ -23,7 +23,7 @@ exports.build_default_stream_table = function () {
const stream_ids = stream_data.get_default_stream_ids();
const subs = stream_ids.map(stream_data.get_sub_by_id);
const streams_list = list_render.create(table, subs, {
list_render.create(table, subs, {
name: "default_streams_list",
modifier: function (item) {
const row = $(render_admin_default_streams_list({
@@ -42,9 +42,8 @@ exports.build_default_stream_table = function () {
},
},
parent_container: $("#admin-default-streams-list").expectOne(),
}).init();
streams_list.sort("alphabetic", "name");
init_sort: ['alphabetic', 'name'],
});
loading.destroy_indicator($('#admin_page_default_streams_loading_indicator'));
};