left_sidebar: Hide menu option for home view if all messages are read.

This commit hides sidebar menu option button instead of showing
it with "Mark all messages as read" option, for home view when
there are no unread messages.
This commit is contained in:
Harsh
2025-03-07 01:02:11 +05:30
committed by Tim Abbott
parent c031cf9275
commit b7a943b8cb
3 changed files with 16 additions and 0 deletions

View File

@@ -76,6 +76,12 @@ export function update_dom_with_unread_counts(
ui_util.update_unread_count_in_dom($streams_header, counts.stream_unread_messages);
ui_util.update_unread_count_in_dom($back_to_streams, counts.stream_unread_messages);
if (counts.home_unread_messages === 0) {
$home_view_li.find(".sidebar-menu-icon").addClass("hide");
} else {
$home_view_li.find(".sidebar-menu-icon").removeClass("hide");
}
if (!skip_animations) {
animate_mention_changes($mentioned_li, counts.mentioned_message_count);
}
@@ -240,6 +246,10 @@ export function handle_home_view_changed(new_home_view: string): void {
const $new_home_view = get_view_rows_by_view_name(new_home_view);
const res = unread.get_counts();
if ($current_home_view.find(".sidebar-menu-icon").hasClass("hide")) {
$current_home_view.find(".sidebar-menu-icon").removeClass("hide");
}
// Remove class from current home view
$current_home_view.removeClass("selected-home-view");

View File

@@ -773,6 +773,10 @@ li.active-sub-filter {
}
}
.sidebar-menu-icon.hide {
visibility: hidden;
}
/* Don't show the scheduled messages item... */
li.top_left_scheduled_messages {
display: none;

View File

@@ -104,6 +104,8 @@ run_test("update_count_in_dom", () => {
stream_unread_messages: 666,
};
$(".selected-home-view").set_find_results(".sidebar-menu-icon", $("<menu-icon>"));
make_elem($(".top_left_mentions"), "<mentioned-count>");
make_elem($(".top_left_inbox"), "<home-count>");