mirror of
https://github.com/zulip/zulip.git
synced 2025-11-03 13:33:24 +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:
@@ -106,8 +106,7 @@ run_test('scrolling', () => {
|
||||
};
|
||||
|
||||
container.html = (html) => { assert.equal(html, ''); };
|
||||
const widget = list_render.create(container, items, opts);
|
||||
widget.init();
|
||||
list_render.create(container, items, opts);
|
||||
|
||||
assert.deepEqual(
|
||||
container.appended_data.html(),
|
||||
@@ -154,7 +153,6 @@ run_test('filtering', () => {
|
||||
|
||||
container.html = (html) => { assert.equal(html, ''); };
|
||||
let widget = list_render.create(container, list, opts);
|
||||
widget.init();
|
||||
|
||||
let expected_html =
|
||||
'<div>apple</div>' +
|
||||
@@ -186,7 +184,7 @@ run_test('filtering', () => {
|
||||
];
|
||||
|
||||
widget.data(new_data);
|
||||
widget.init();
|
||||
widget.redraw();
|
||||
expected_html =
|
||||
'<div>greta</div>' +
|
||||
'<div>gary</div>' +
|
||||
|
||||
Reference in New Issue
Block a user