left_sidebar: Improve logic for showing Scheduled messages.

This commit is contained in:
Karl Stolley 2023-10-16 14:41:23 -05:00 committed by Tim Abbott
parent 46ce408a5f
commit 41635566fd
4 changed files with 23 additions and 3 deletions

View File

@ -15,9 +15,9 @@ export function update_scheduled_messages_row() {
const $scheduled_li = $(".top_left_scheduled_messages");
const count = scheduled_messages.get_count();
if (count > 0) {
$scheduled_li.show();
$scheduled_li.addClass("show-with-scheduled-messages");
} else {
$scheduled_li.hide();
$scheduled_li.removeClass("show-with-scheduled-messages");
}
ui_util.update_unread_count_in_dom($scheduled_li, count);
}

View File

@ -108,8 +108,17 @@ export function initialize() {
popover_menus.register_popover_menu(".left-sidebar-navigation-menu-icon", {
...popover_menus.left_sidebar_tippy_options,
onShow(instance) {
// Determine at show time whether there are scheduled messages,
// so that Tippy properly calculates the height of the popover
const scheduled_message_count = scheduled_messages.get_count();
let has_scheduled_messages = false;
if (scheduled_message_count > 0) {
has_scheduled_messages = true;
}
popovers.hide_all();
instance.setContent(parse_html(render_left_sidebar_condensed_views_popover()));
instance.setContent(
parse_html(render_left_sidebar_condensed_views_popover({has_scheduled_messages})),
);
},
onMount() {
update_unread_count_in_dom(

View File

@ -615,6 +615,15 @@ li.top_left_scheduled_messages {
}
}
/* Don't show the scheduled messages item... */
li.top_left_scheduled_messages {
display: none;
/* ...unless there are scheduled messages to show. */
&.show-with-scheduled-messages {
display: list-item;
}
}
.top_left_row {
padding-left: $far_left_gutter_size;
padding-right: 10px;

View File

@ -10,6 +10,7 @@
<span class="unread_count"></span>
</a>
</li>
{{#if has_scheduled_messages }}
<li class="condensed-views-popover-menu-scheduled-messages">
<a tabindex="0" href="#scheduled" class="left-sidebar-popover-icon-label-count">
<span class="filter-icon">
@ -19,4 +20,5 @@
<span class="unread_count"></span>
</a>
</li>
{{/if}}
</ul>