diff --git a/frontend_tests/node_tests/activity.js b/frontend_tests/node_tests/activity.js index 29d1da42d8..55ba7e78f4 100644 --- a/frontend_tests/node_tests/activity.js +++ b/frontend_tests/node_tests/activity.js @@ -240,6 +240,8 @@ presence.presence_info[mark.user_id] = { status: activity.IDLE }; presence.presence_info[norbert.user_id] = { status: activity.ACTIVE }; presence.presence_info[zoe.user_id] = { status: activity.ACTIVE }; +activity.set_user_list_filter(); + (function test_presence_list_full_update() { var users = activity.build_user_sidebar(); assert.deepEqual(users, [{ @@ -369,6 +371,7 @@ $('.user-list-filter').is = function (sel) { }; compose_actions.start = function () {}; + activity.set_user_list_filter_handlers(); var keydown_handler = $('.user-list-filter').get_on_handler('keydown'); keydown_handler(e); }()); @@ -504,7 +507,7 @@ presence.presence_info[zoe.user_id] = { status: activity.ACTIVE }; // Reset jquery here. set_global('$', global.make_zjquery()); -activity.initialize_filter_state(); +activity.set_user_list_filter(); (function test_insert_unfiltered_user_with_filter() { // This test only tests that we do not explode when diff --git a/static/js/activity.js b/static/js/activity.js index 465b79529f..55b31c1e77 100644 --- a/static/js/activity.js +++ b/static/js/activity.js @@ -488,9 +488,14 @@ exports.initialize = function () { page_params.initial_servertime); delete page_params.presences; + exports.set_user_list_filter(); + exports.build_user_sidebar(); exports.update_huddles(); + exports.set_user_list_filter_handlers(); + + $('#clear_search_people_button').on('click', exports.clear_search); // Let the server know we're here, but pass "false" for // want_redraw, since we just got all this info in page_params. focus_ping(false); @@ -598,21 +603,18 @@ function focus_user_filter(e) { update_clear_search_button(); } -exports.initialize_filter_state = function () { +exports.set_user_list_filter = function () { meta.$user_list_filter = $(".user-list-filter"); +}; +exports.set_user_list_filter_handlers = function () { meta.$user_list_filter.expectOne() .on('click', focus_user_filter) .on('input', update_users_for_search) .on('keydown', maybe_select_person) .on('blur', update_clear_search_button); - $('#clear_search_people_button').on('click', exports.clear_search); }; -$(function () { - exports.initialize_filter_state(); -}); - return exports; }());