server_events: Fix infinite loading indicator on page load.

Hiding the loading indicator was based on us adding some messages
into the view which was no always the case.
This commit is contained in:
Aman Agrawal 2024-05-16 12:14:22 +00:00 committed by Tim Abbott
parent 62c682b2e1
commit aa31f9ae8d
3 changed files with 6 additions and 5 deletions

View File

@ -1,7 +1,4 @@
import $ from "jquery";
import {all_messages_data} from "./all_messages_data"; import {all_messages_data} from "./all_messages_data";
import * as loading from "./loading";
import type {MessageListData} from "./message_list_data"; import type {MessageListData} from "./message_list_data";
import type {MessageList, RenderInfo} from "./message_lists"; import type {MessageList, RenderInfo} from "./message_lists";
import * as message_store from "./message_store"; import * as message_store from "./message_store";
@ -28,8 +25,6 @@ export function add_messages(
return undefined; return undefined;
} }
loading.destroy_indicator($("#page_loading_indicator"));
const render_info = msg_list.add_messages(messages, append_to_view_opts); const render_info = msg_list.add_messages(messages, append_to_view_opts);
return render_info; return render_info;

View File

@ -4,6 +4,7 @@ import _ from "lodash";
import * as blueslip from "./blueslip"; import * as blueslip from "./blueslip";
import * as channel from "./channel"; import * as channel from "./channel";
import * as echo from "./echo"; import * as echo from "./echo";
import * as loading from "./loading";
import * as message_events from "./message_events"; import * as message_events from "./message_events";
import {page_params} from "./page_params"; import {page_params} from "./page_params";
import * as reload from "./reload"; import * as reload from "./reload";
@ -282,6 +283,8 @@ export function force_get_events() {
export function finished_initial_fetch() { export function finished_initial_fetch() {
waiting_on_initial_fetch = false; waiting_on_initial_fetch = false;
get_events_success([]); get_events_success([]);
// Destroy loading indicator after we added fetched messages.
loading.destroy_indicator($("#page_loading_indicator"));
} }
export function initialize(params) { export function initialize(params) {

View File

@ -7,6 +7,9 @@ const {run_test, noop} = require("./lib/test");
const blueslip = require("./lib/zblueslip"); const blueslip = require("./lib/zblueslip");
const {page_params} = require("./lib/zpage_params"); const {page_params} = require("./lib/zpage_params");
mock_esm("../src/loading", {
destroy_indicator: noop,
});
set_global("addEventListener", noop); set_global("addEventListener", noop);
const channel = mock_esm("../src/channel"); const channel = mock_esm("../src/channel");