diff --git a/frontend_tests/node_tests/unread.js b/frontend_tests/node_tests/unread.js index a119ff638c..754d6179e1 100644 --- a/frontend_tests/node_tests/unread.js +++ b/frontend_tests/node_tests/unread.js @@ -699,32 +699,34 @@ test("message_unread", () => { test("server_counts", () => { // note that user_id 30 is "me" - page_params.unread_msgs = { - pms: [ - { - other_user_id: 101, - // sender_id is deprecated. - sender_id: 101, - unread_message_ids: [31, 32, 60, 61, 62, 63], - }, - ], - huddles: [ - { - user_ids_string: "4,6,30,101", - unread_message_ids: [34, 50], - }, - ], - streams: [ - { - stream_id: 1, - topic: "test", - unread_message_ids: [33, 35, 36], - }, - ], - mentions: [31, 34, 40, 41], + const unread_params = { + unread_msgs: { + pms: [ + { + other_user_id: 101, + // sender_id is deprecated. + sender_id: 101, + unread_message_ids: [31, 32, 60, 61, 62, 63], + }, + ], + huddles: [ + { + user_ids_string: "4,6,30,101", + unread_message_ids: [34, 50], + }, + ], + streams: [ + { + stream_id: 1, + topic: "test", + unread_message_ids: [33, 35, 36], + }, + ], + mentions: [31, 34, 40, 41], + }, }; - unread.initialize(); + unread.initialize(unread_params); assert.equal(unread.num_unread_for_user_ids_string("101"), 6); assert.equal(unread.num_unread_for_user_ids_string("4,6,101"), 2); diff --git a/static/js/ui_init.js b/static/js/ui_init.js index 14573ba648..7d4515d93b 100644 --- a/static/js/ui_init.js +++ b/static/js/ui_init.js @@ -558,6 +558,8 @@ export function initialize_everything() { const user_groups_params = pop_fields("realm_user_groups"); + const unread_params = pop_fields("unread_msgs"); + const user_status_params = pop_fields("user_status"); const i18n_params = pop_fields("language_list"); const user_settings_params = pop_fields("user_settings"); @@ -648,7 +650,7 @@ export function initialize_everything() { search_pill_widget.initialize(); reload.initialize(); user_groups.initialize(user_groups_params); - unread.initialize(); + unread.initialize(unread_params); bot_data.initialize(bot_params); // Must happen after people.initialize() message_fetch.initialize(server_events.home_view_loaded); message_scroll.initialize(); diff --git a/static/js/unread.js b/static/js/unread.js index 0e2d060dcb..b4b8087381 100644 --- a/static/js/unread.js +++ b/static/js/unread.js @@ -793,8 +793,8 @@ export function get_msg_ids_for_starred() { return []; } -export function initialize() { - const unread_msgs = page_params.unread_msgs; +export function initialize(params) { + const unread_msgs = params.unread_msgs; unread_pm_counter.set_huddles(unread_msgs.huddles); unread_pm_counter.set_pms(unread_msgs.pms);