mirror of https://github.com/zulip/zulip.git
refactor: Make home_view_loaded into a callback.
This reduces our extraneous deps from 72 to 71.
This commit is contained in:
parent
c67f82b073
commit
98372cd244
|
@ -32,7 +32,6 @@ const channel = mock_esm("../../static/js/channel");
|
||||||
const message_store = mock_esm("../../static/js/message_store");
|
const message_store = mock_esm("../../static/js/message_store");
|
||||||
const message_util = mock_esm("../../static/js/message_util");
|
const message_util = mock_esm("../../static/js/message_util");
|
||||||
const pm_list = mock_esm("../../static/js/pm_list");
|
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", {
|
const stream_list = mock_esm("../../static/js/stream_list", {
|
||||||
maybe_scroll_narrow_into_view: () => {},
|
maybe_scroll_narrow_into_view: () => {},
|
||||||
});
|
});
|
||||||
|
@ -58,8 +57,6 @@ const alice = {
|
||||||
};
|
};
|
||||||
people.add_active_user(alice);
|
people.add_active_user(alice);
|
||||||
|
|
||||||
server_events.home_view_loaded = noop;
|
|
||||||
|
|
||||||
function stub_message_view(list) {
|
function stub_message_view(list) {
|
||||||
list.view.append = noop;
|
list.view.append = noop;
|
||||||
list.view.maybe_rerender = noop;
|
list.view.maybe_rerender = noop;
|
||||||
|
@ -209,7 +206,7 @@ function test_fetch_success(opts) {
|
||||||
process_results.verify();
|
process_results.verify();
|
||||||
}
|
}
|
||||||
|
|
||||||
function initial_fetch_step() {
|
function initial_fetch_step(home_view_loaded) {
|
||||||
const self = {};
|
const self = {};
|
||||||
|
|
||||||
let fetch;
|
let fetch;
|
||||||
|
@ -220,7 +217,7 @@ function initial_fetch_step() {
|
||||||
expected_opts_data: initialize_data.initial_fetch.req,
|
expected_opts_data: initialize_data.initial_fetch.req,
|
||||||
});
|
});
|
||||||
|
|
||||||
message_fetch.initialize();
|
message_fetch.initialize(home_view_loaded);
|
||||||
};
|
};
|
||||||
|
|
||||||
self.finish = () => {
|
self.finish = () => {
|
||||||
|
@ -283,7 +280,13 @@ function test_backfill_idle(idle_config) {
|
||||||
run_test("initialize", () => {
|
run_test("initialize", () => {
|
||||||
reset_lists();
|
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();
|
step1.prep();
|
||||||
|
|
||||||
|
@ -292,7 +295,9 @@ run_test("initialize", () => {
|
||||||
step2.prep();
|
step2.prep();
|
||||||
step1.finish();
|
step1.finish();
|
||||||
|
|
||||||
|
assert(!home_loaded);
|
||||||
const idle_config = step2.finish();
|
const idle_config = step2.finish();
|
||||||
|
assert(home_loaded);
|
||||||
|
|
||||||
test_backfill_idle(idle_config);
|
test_backfill_idle(idle_config);
|
||||||
});
|
});
|
||||||
|
|
|
@ -12,7 +12,6 @@ import {page_params} from "./page_params";
|
||||||
import * as people from "./people";
|
import * as people from "./people";
|
||||||
import * as pm_list from "./pm_list";
|
import * as pm_list from "./pm_list";
|
||||||
import * as recent_topics from "./recent_topics";
|
import * as recent_topics from "./recent_topics";
|
||||||
import * as server_events from "./server_events";
|
|
||||||
import * as stream_data from "./stream_data";
|
import * as stream_data from "./stream_data";
|
||||||
import * as stream_list from "./stream_list";
|
import * as stream_list from "./stream_list";
|
||||||
import * as ui_report from "./ui_report";
|
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 list
|
// get the initial message list
|
||||||
function load_more(data) {
|
function load_more(data) {
|
||||||
// If we haven't selected a message in the home view yet, and
|
// If we haven't selected a message in the home view yet, and
|
||||||
|
@ -420,7 +419,8 @@ export function initialize() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.found_newest) {
|
if (data.found_newest) {
|
||||||
server_events.home_view_loaded();
|
// See server_events.js for this callback.
|
||||||
|
home_view_loaded();
|
||||||
start_backfilling_messages();
|
start_backfilling_messages();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -506,7 +506,7 @@ export function initialize_everything() {
|
||||||
user_groups.initialize(user_groups_params);
|
user_groups.initialize(user_groups_params);
|
||||||
unread.initialize();
|
unread.initialize();
|
||||||
bot_data.initialize(bot_params); // Must happen after people.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();
|
message_scroll.initialize();
|
||||||
emoji.initialize({
|
emoji.initialize({
|
||||||
realm_emoji: emoji_params.realm_emoji,
|
realm_emoji: emoji_params.realm_emoji,
|
||||||
|
|
Loading…
Reference in New Issue