diff --git a/crates/collab_ui/src/notification_panel.rs b/crates/collab_ui/src/notification_panel.rs index 9f69b7144c..7bf5000ec8 100644 --- a/crates/collab_ui/src/notification_panel.rs +++ b/crates/collab_ui/src/notification_panel.rs @@ -299,6 +299,19 @@ impl NotificationPanel { .into_any() } + fn render_empty_state( + &self, + theme: &Arc, + _cx: &mut ViewContext, + ) -> AnyElement { + Label::new( + "You have no notifications".to_string(), + theme.chat_panel.sign_in_prompt.default.clone(), + ) + .aligned() + .into_any() + } + fn on_notification_event( &mut self, _: ModelHandle, @@ -373,13 +386,15 @@ impl View for NotificationPanel { fn render(&mut self, cx: &mut ViewContext) -> AnyElement { let theme = theme::current(cx); - let element = if self.client.user_id().is_some() { + let element = if self.client.user_id().is_none() { + self.render_sign_in_prompt(&theme, cx) + } else if self.notification_list.item_count() == 0 { + self.render_empty_state(&theme, cx) + } else { List::new(self.notification_list.clone()) .contained() .with_style(theme.chat_panel.list) .into_any() - } else { - self.render_sign_in_prompt(&theme, cx) }; element .contained() diff --git a/crates/gpui/src/elements/list.rs b/crates/gpui/src/elements/list.rs index a23b6fc5e3..eaa09a0392 100644 --- a/crates/gpui/src/elements/list.rs +++ b/crates/gpui/src/elements/list.rs @@ -378,6 +378,10 @@ impl ListState { .extend((0..element_count).map(|_| ListItem::Unrendered), &()); } + pub fn item_count(&self) -> usize { + self.0.borrow().items.summary().count + } + pub fn splice(&self, old_range: Range, count: usize) { let state = &mut *self.0.borrow_mut();