Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

message_feed: Hide top-of-feed logo once full history is fetched.

Shubham Padiae65ed086343d
diff --git a/web/src/message_feed_top_notices.ts b/web/src/message_feed_top_notices.ts
index 68712d56bf8..3807b1d801e 100644
--- a/web/src/message_feed_top_notices.ts
+++ b/web/src/message_feed_top_notices.ts
@@ -8,7 +8,6 @@ import * as narrow_state from "./narrow_state.ts";
import {page_params} from "./page_params.ts";
function show_history_limit_notice(): void {
- $(".top-messages-logo").hide();
$(".history-limited-box").show();
// The history-limit notice and the empty-narrow banner are mutually
// exclusive top-of-feed states; clear the latter when showing this.
@@ -18,7 +17,6 @@ function show_history_limit_notice(): void {
}
function hide_history_limit_notice(): void {
- $(".top-messages-logo").show();
$(".history-limited-box").hide();
}
@@ -28,13 +26,10 @@ function hide_end_of_results_notice(): void {
}
function show_end_of_results_notice(): void {
- // Both end-of-results notices are hidden for spectators, so leave the
- // top-of-feed logo in place for them rather than hiding it and showing
- // nothing.
+ // Both end-of-results notices are hidden for spectators.
if (page_params.is_spectator) {
return;
}
- $(".top-messages-logo").hide();
const narrow_filter = narrow_state.filter();
assert(narrow_filter !== undefined);
@@ -51,6 +46,14 @@ function show_end_of_results_notice(): void {
$(".all-messages-search-caution .search-shared-history").attr("data-url", update_hash);
}
+export function update_top_of_feed_logo(): void {
+ if (message_lists.current?.data.fetch_status.has_found_oldest()) {
+ $(".top-messages-logo").hide();
+ } else {
+ $(".top-messages-logo").show();
+ }
+}
+
export function update_top_of_narrow_notices(msg_list: MessageList): void {
// Assumes that the current state is all notices hidden (i.e. this
// will not hide a notice that should not be there)
@@ -58,6 +61,8 @@ export function update_top_of_narrow_notices(msg_list: MessageList): void {
return;
}
+ update_top_of_feed_logo();
+
if (msg_list.data.fetch_status.has_found_oldest()) {
const filter = narrow_state.filter();
// Potentially display the notice that lets users know
@@ -77,6 +82,11 @@ export function update_top_of_narrow_notices(msg_list: MessageList): void {
}
export function hide_top_of_narrow_notices(): void {
+ // Restore the top-of-feed logo; this runs when resetting for a new
+ // narrow, whose fetch status we don't know yet. It is hidden again
+ // once we learn we have the narrow's oldest message (see
+ // update_top_of_feed_logo).
+ $(".top-messages-logo").show();
hide_end_of_results_notice();
hide_history_limit_notice();
}
diff --git a/web/src/narrow_banner.ts b/web/src/narrow_banner.ts
index 190727cb897..2d44a111d59 100644
--- a/web/src/narrow_banner.ts
+++ b/web/src/narrow_banner.ts
@@ -644,8 +644,12 @@ export function show_empty_narrow_message(current_filter: Filter, invalid_narrow
// Removing messages from the current narrow can leave a stale
// top-of-feed notice visible, so hide all of them before showing
- // the empty-narrow banner.
+ // the empty-narrow banner. Hiding the notices restores the
+ // top-of-feed logo, so re-evaluate whether it should be visible;
+ // an empty narrow whose history is fully fetched should not
+ // suggest that more messages may load above.
message_feed_top_notices.hide_top_of_narrow_notices();
+ message_feed_top_notices.update_top_of_feed_logo();
if (current_filter.may_have_incomplete_message_history()) {
$(".empty_feed_notice .empty-feed-notice-action").show();