mirror of
https://github.com/zulip/zulip.git
synced 2025-11-03 21:43:21 +00:00
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:
@@ -46,7 +46,7 @@ function populate_invites(invites_data) {
|
||||
|
||||
const invites_table = $("#admin_invites_table").expectOne();
|
||||
|
||||
const invites_list = list_render.create(invites_table, invites_data.invites, {
|
||||
list_render.create(invites_table, invites_data.invites, {
|
||||
name: 'admin_invites_list',
|
||||
modifier: function (item) {
|
||||
item.invited_absolute_time = timerender.absolute_time(item.invited * 1000);
|
||||
@@ -64,11 +64,12 @@ function populate_invites(invites_data) {
|
||||
},
|
||||
},
|
||||
parent_container: $("#admin-invites-list").expectOne(),
|
||||
init_sort: [sort_invitee],
|
||||
sort_fields: {
|
||||
invitee: sort_invitee,
|
||||
},
|
||||
});
|
||||
|
||||
invites_list.sort('invitee');
|
||||
invites_list.add_sort_function('invitee', sort_invitee);
|
||||
|
||||
loading.destroy_indicator($('#admin_page_invites_loading_indicator'));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user