Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
recent_view: Show load-more inline in empty state instead of banner.
Aman Agrawalc28086693e50
diff --git a/web/src/recent_view_ui.ts b/web/src/recent_view_ui.tsindex 6dc4232508d..1f0f2e1ba83 100644--- a/web/src/recent_view_ui.ts+++ b/web/src/recent_view_ui.ts@@ -5,6 +5,7 @@ import type * as tippy from "tippy.js";import * as z from "zod/mini";import render_introduce_zulip_view_modal from "../templates/introduce_zulip_view_modal.hbs";+import render_recent_view_empty_list_widget_for_table from "../templates/recent_view_empty_list_widget_for_table.hbs";import render_recent_view_filters from "../templates/recent_view_filters.hbs";import render_recent_view_row from "../templates/recent_view_row.hbs";import render_recent_view_body from "../templates/recent_view_table.hbs";@@ -234,6 +235,16 @@ function get_loaded_messages_text(): string {return $t({defaultMessage: "Showing messages since {time_string}."}, {time_string});}+function render_recent_view_empty_list_widget_for_table_with_load_more(context: {+ empty_list_message: string;+ column_count: number;+}): string {+ return render_recent_view_empty_list_widget_for_table({+ ...context,+ load_more_button_text: $t({defaultMessage: "Load more"}),+ });+}+function update_load_more_banner(): void {if (loading_state === NO_MESSAGES_LOADED) {return;@@ -241,6 +252,7 @@ function update_load_more_banner(): void {if (loading_state === ALL_MESSAGES_LOADED) {$(".recent-view-load-more-container").toggleClass("notvisible", true);+ $(".recent-view-empty-load-more").toggleClass("notvisible", true);return;}@@ -249,35 +261,37 @@ function update_load_more_banner(): void {return;}- // There are some messages loaded, but not all messages yet. The banner was- // hidden on page load, and we make sure to show it now that there are messages- // we can display.- $(".recent-view-load-more-container").toggleClass("notvisible", false);-- // Until we've found the newest message, we only show the banner with a messages- // explaining we're still fetching messages. We don't allow the user to fetch- // more messages.+ // Until we've found the newest message, we only show the banner+ // explaining we're still fetching messages. We don't allow the+ // user to fetch more messages.if (loading_state === SOME_MESSAGES_LOADED) {+ $(".recent-view-load-more-container").toggleClass("notvisible", false);return;}- const $banner_text = $(".recent-view-load-more-container .last-fetched-message");- $banner_text.text(get_loaded_messages_text());+ // When the table is empty, show the load-more text inline below+ // "No conversations match your filters." and hide the banner.+ // Otherwise, show the banner and hide the inline load-more.+ assert(topics_widget !== undefined);+ const is_table_empty = topics_widget.get_current_list().length === 0;+ $(".recent-view-load-more-container").toggleClass("notvisible", is_table_empty);+ $(".recent-view-empty-load-more").toggleClass("notvisible", !is_table_empty);++ const $container = is_table_empty+ ? $(".recent-view-empty-load-more")+ : $(".recent-view-load-more-container");+ $container.find(".last-fetched-message").text(get_loaded_messages_text());if (is_backfill_in_progress) {// Keep the button disabled and the loading indicator running// until we've finished our recursive backfill.return;}- const $button = $(".recent-view-load-more-container .fetch-messages-button");- const $button_label = $(".recent-view-load-more-container .button-label");+ const $button = $container.find(".fetch-messages-button");$button.toggleClass("notvisible", false);-- $button_label.toggleClass("invisible", false);+ $button.find(".button-label").toggleClass("invisible", false);$button.prop("disabled", false);- loading.destroy_indicator(- $(".recent-view-load-more-container .fetch-messages-button .loading-indicator"),- );+ loading.destroy_indicator($button.find(".loading-indicator"));}function get_min_load_count(already_rendered_count: number, load_count: number): number {@@ -1565,6 +1579,8 @@ export function complete_rerender(coming_from_other_views = false): void {html_selector: get_topic_row,$simplebar_container: $(":root"),callback_after_render,+ render_empty_list_widget_for_table:+ render_recent_view_empty_list_widget_for_table_with_load_more,is_scroll_position_for_render: views_util.is_scroll_position_for_render,post_scroll__pre_render_callback() {// Update the focused element for keyboard navigation if needed.@@ -2258,7 +2274,7 @@ export function initialize({$("body").on("click",- ".recent-view-load-more-container .fetch-messages-button",+ ".recent-view-load-more-container .fetch-messages-button, .recent-view-empty-load-more .fetch-messages-button",function (this: HTMLElement) {const $button = $(this);$button.find(".button-label").toggleClass("invisible", true);diff --git a/web/styles/recent_view.css b/web/styles/recent_view.cssindex b9f2b08af87..0edc853e8bc 100644--- a/web/styles/recent_view.css+++ b/web/styles/recent_view.css@@ -119,6 +119,18 @@padding: 3em 1em;}+ .recent-view-empty-load-more {+ margin-top: 10px;+ display: flex;+ flex-direction: column;+ align-items: center;+ gap: 10px;+ /* Reset the 1.5em font-size inherited from+ .empty-table-message so the load-more text+ and button match normal UI text size. */+ font-size: var(--base-font-size-px);+ }+.fa-check-square-o,.fa-square-o {width: 0.7142em; /* Legacy 10px size at 14px/1em. */diff --git a/web/templates/recent_view_empty_list_widget_for_table.hbs b/web/templates/recent_view_empty_list_widget_for_table.hbsnew file mode 100644index 00000000000..08198e638c2--- /dev/null+++ b/web/templates/recent_view_empty_list_widget_for_table.hbs@@ -0,0 +1,12 @@+<tr>+ <td class="empty-table-message" colspan="{{column_count}}">+ {{empty_list_message}}+ <div class="recent-view-empty-load-more notvisible">+ <p class="last-fetched-message"></p>+ <button class="fetch-messages-button action-button action-button-subtle-brand notvisible">+ <span class="loading-indicator"></span>+ <span class="button-label">{{load_more_button_text}}</span>+ </button>+ </div>+ </td>+</tr>