Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Add an empty state to the notification panel
Max Brunsfeldc66385f0f909
diff --git a/crates/collab_ui/src/notification_panel.rs b/crates/collab_ui/src/notification_panel.rsindex 9f69b7144c3..7bf5000ec87 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<Theme>,+ _cx: &mut ViewContext<Self>,+ ) -> AnyElement<Self> {+ 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<NotificationStore>,@@ -373,13 +386,15 @@ impl View for NotificationPanel {fn render(&mut self, cx: &mut ViewContext<Self>) -> AnyElement<Self> {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.rsindex a23b6fc5e3e..eaa09a0392d 100644--- a/crates/gpui/src/elements/list.rs+++ b/crates/gpui/src/elements/list.rs@@ -378,6 +378,10 @@ impl<V: 'static> ListState<V> {.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<usize>, count: usize) {let state = &mut *self.0.borrow_mut();