diff --git a/frontend_tests/node_tests/list_render.js b/frontend_tests/node_tests/list_render.js index 674d867764..20fdb25314 100644 --- a/frontend_tests/node_tests/list_render.js +++ b/frontend_tests/node_tests/list_render.js @@ -185,8 +185,7 @@ run_test('filtering', () => { 'fox', ]; - widget.data(new_data); - widget.clean_redraw(); + widget.replace_list_data(new_data); expected_html = '
greta
' + '
gary
' + diff --git a/static/js/list_render.js b/static/js/list_render.js index a7378b6a62..3308be66bd 100644 --- a/static/js/list_render.js +++ b/static/js/list_render.js @@ -128,32 +128,6 @@ exports.create = function ($container, list, opts) { meta.offset += load_count; }; - // reset the data associated with a list. This is so that instead of - // initializing a new progressive list render instance, you can just - // update the data of an existing one. - widget.data = function (...args) { - // if no args are provided then just return the existing data. - // this interface is similar to how many jQuery functions operate, - // where a call to the method without data returns the existing data. - if (args.length === 0) { - return meta.list; - } - const [data] = args; - - if (Array.isArray(data)) { - meta.list = data; - meta.filtered_list = data; - - widget.filter_and_sort(); - widget.clear(); - - return; - } - - blueslip.warn("The data object provided to the progressive" + - " list render is invalid"); - }; - widget.clear = function () { $container.html(""); meta.offset = 0; @@ -245,6 +219,16 @@ exports.create = function ($container, list, opts) { } }; + widget.replace_list_data = function (list) { + /* + We mostly use this widget for lists where you are + not adding or removing rows, so when you do modify + the list, we have a brute force solution. + */ + meta.list = list; + widget.hard_redraw(); + }; + // add built-in generic sort functions. widget.add_generic_sort_function("alphabetic", function (prop) { return function (a, b) { diff --git a/static/js/stream_ui_updates.js b/static/js/stream_ui_updates.js index c8d19c7447..67ec718a7e 100644 --- a/static/js/stream_ui_updates.js +++ b/static/js/stream_ui_updates.js @@ -188,8 +188,7 @@ exports.update_subscribers_list = function (sub) { // stream is open. if (subscribers_list) { stream_edit.sort_but_pin_current_user_on_top(users); - subscribers_list.data(users); - subscribers_list.clean_redraw(); + subscribers_list.replace_list_data(users); } $(".subscriber_list_settings_container").show(); }