From fed1eaf7d78208373a0d774f8173bb8c554d3fce Mon Sep 17 00:00:00 2001 From: Steve Howell Date: Wed, 17 Feb 2021 11:55:17 +0000 Subject: [PATCH] minor: Inline filter_table in subs.js. The old structure of having a two-line wrapper was mostly driven by testing concerns. Now I just have a single function with the optional argument. --- frontend_tests/node_tests/subs.js | 4 ++-- static/js/subs.js | 13 +++++++------ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/frontend_tests/node_tests/subs.js b/frontend_tests/node_tests/subs.js index df9eba31b1..83d4f65d4e 100644 --- a/frontend_tests/node_tests/subs.js +++ b/frontend_tests/node_tests/subs.js @@ -27,7 +27,7 @@ set_global("hash_util", { by_stream_uri: () => {}, }); -run_test("filter_table", (override) => { +run_test("redraw_left_panel", (override) => { override(subs, "add_tooltip_to_left_panel_row", () => {}); // set-up sub rows stubs @@ -124,7 +124,7 @@ run_test("filter_table", (override) => { assert(!denmark_row.hasClass("active")); function test_filter(params, expected_streams) { - const stream_ids = subs.filter_table(params); + const stream_ids = subs.redraw_left_panel(params); assert.deepEqual( stream_ids, expected_streams.map((sub) => sub.stream_id), diff --git a/static/js/subs.js b/static/js/subs.js index c3066d0d59..3f4190ba9e 100644 --- a/static/js/subs.js +++ b/static/js/subs.js @@ -429,7 +429,13 @@ exports.render_left_panel_superset = function () { }; // LeftPanelParams { input: String, subscribed_only: Boolean, sort_order: String } -exports.filter_table = function (left_panel_params) { +exports.redraw_left_panel = function (left_panel_params) { + // We only get left_panel_params passed in from tests. Real + // code calls get_left_panel_params(). + if (left_panel_params === undefined) { + left_panel_params = exports.get_left_panel_params(); + } + exports.show_active_stream_in_left_panel(); function stream_id_for_row(row) { @@ -508,11 +514,6 @@ exports.maybe_reset_right_panel = function () { } }; -exports.redraw_left_panel = function () { - const left_panel_params = exports.get_left_panel_params(); - exports.filter_table(left_panel_params); -}; - // Make it explicit that our toggler is not created right away. exports.toggler = undefined;