Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
refactor: Make home_view_loaded into a callback.
Steve Howell98372cd244d8
diff --git a/frontend_tests/node_tests/message_fetch.js b/frontend_tests/node_tests/message_fetch.jsindex dcb4a91416a..f555c9efa4d 100644--- a/frontend_tests/node_tests/message_fetch.js+++ b/frontend_tests/node_tests/message_fetch.js@@ -32,7 +32,6 @@ const channel = mock_esm("../../static/js/channel");const message_store = mock_esm("../../static/js/message_store");const message_util = mock_esm("../../static/js/message_util");const pm_list = mock_esm("../../static/js/pm_list");-const server_events = mock_esm("../../static/js/server_events");const stream_list = mock_esm("../../static/js/stream_list", {maybe_scroll_narrow_into_view: () => {},});@@ -58,8 +57,6 @@ const alice = {};people.add_active_user(alice);-server_events.home_view_loaded = noop;-function stub_message_view(list) {list.view.append = noop;list.view.maybe_rerender = noop;@@ -209,7 +206,7 @@ function test_fetch_success(opts) {process_results.verify();}-function initial_fetch_step() {+function initial_fetch_step(home_view_loaded) {const self = {};let fetch;@@ -220,7 +217,7 @@ function initial_fetch_step() {expected_opts_data: initialize_data.initial_fetch.req,});- message_fetch.initialize();+ message_fetch.initialize(home_view_loaded);};self.finish = () => {@@ -283,7 +280,13 @@ function test_backfill_idle(idle_config) {run_test("initialize", () => {reset_lists();- const step1 = initial_fetch_step();+ let home_loaded = false;++ function home_view_loaded() {+ home_loaded = true;+ }++ const step1 = initial_fetch_step(home_view_loaded);step1.prep();@@ -292,7 +295,9 @@ run_test("initialize", () => {step2.prep();step1.finish();+ assert(!home_loaded);const idle_config = step2.finish();+ assert(home_loaded);test_backfill_idle(idle_config);});diff --git a/static/js/message_fetch.js b/static/js/message_fetch.jsindex 528396094f6..f0efb3d59d2 100644--- a/static/js/message_fetch.js+++ b/static/js/message_fetch.js@@ -12,7 +12,6 @@ import {page_params} from "./page_params";import * as people from "./people";import * as pm_list from "./pm_list";import * as recent_topics from "./recent_topics";-import * as server_events from "./server_events";import * as stream_data from "./stream_data";import * as stream_list from "./stream_list";import * as ui_report from "./ui_report";@@ -403,7 +402,7 @@ export function start_backfilling_messages() {});}-export function initialize() {+export function initialize(home_view_loaded) {// get the initial message listfunction load_more(data) {// If we haven't selected a message in the home view yet, and@@ -420,7 +419,8 @@ export function initialize() {}if (data.found_newest) {- server_events.home_view_loaded();+ // See server_events.js for this callback.+ home_view_loaded();start_backfilling_messages();return;}diff --git a/static/js/ui_init.js b/static/js/ui_init.jsindex 8fc9102d7e9..8a17e3d67d3 100644--- a/static/js/ui_init.js+++ b/static/js/ui_init.js@@ -506,7 +506,7 @@ export function initialize_everything() {user_groups.initialize(user_groups_params);unread.initialize();bot_data.initialize(bot_params); // Must happen after people.initialize()- message_fetch.initialize();+ message_fetch.initialize(server_events.home_view_loaded);message_scroll.initialize();emoji.initialize({realm_emoji: emoji_params.realm_emoji,