From 70eeefa1f899f6a0b866c6d2d2318f90cf60f79d Mon Sep 17 00:00:00 2001 From: Conrad Irwin Date: Wed, 25 Oct 2023 09:27:17 +0200 Subject: [PATCH] Fix channel collapsing --- crates/channel/src/channel_store.rs | 7 ------- crates/collab_ui/src/collab_panel.rs | 19 +++++++++++++++---- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/crates/channel/src/channel_store.rs b/crates/channel/src/channel_store.rs index 14738e170b..9757bb8092 100644 --- a/crates/channel/src/channel_store.rs +++ b/crates/channel/src/channel_store.rs @@ -188,13 +188,6 @@ impl ChannelStore { self.client.clone() } - pub fn channel_has_children(&self) -> bool { - self.channel_index - .by_id() - .iter() - .any(|(_, channel)| channel.parent_path.contains(&channel.id)) - } - /// Returns the number of unique channels in the store pub fn channel_count(&self) -> usize { self.channel_index.by_id().len() diff --git a/crates/collab_ui/src/collab_panel.rs b/crates/collab_ui/src/collab_panel.rs index 51eab1eb3f..66962b0402 100644 --- a/crates/collab_ui/src/collab_panel.rs +++ b/crates/collab_ui/src/collab_panel.rs @@ -472,9 +472,20 @@ impl CollabPanel { cx, ) } - ListEntry::Channel { channel, depth, .. } => { - let channel_row = - this.render_channel(&*channel, *depth, &theme, is_selected, ix, cx); + ListEntry::Channel { + channel, + depth, + has_children, + } => { + let channel_row = this.render_channel( + &*channel, + *depth, + &theme, + is_selected, + *has_children, + ix, + cx, + ); if is_selected && this.context_menu_on_selected { Stack::new() @@ -1867,12 +1878,12 @@ impl CollabPanel { depth: usize, theme: &theme::Theme, is_selected: bool, + has_children: bool, ix: usize, cx: &mut ViewContext, ) -> AnyElement { let channel_id = channel.id; let collab_theme = &theme.collab_panel; - let has_children = self.channel_store.read(cx).channel_has_children(); let is_public = self .channel_store .read(cx)