diff --git a/crates/collab_ui/src/channel_view.rs b/crates/collab_ui/src/channel_view.rs index bb7192026ee97c137f149ff94ea5cf356d18d716..acbb80c36a9d7fa8d5c02ce7ab3c12c3cb7aa22d 100644 --- a/crates/collab_ui/src/channel_view.rs +++ b/crates/collab_ui/src/channel_view.rs @@ -393,6 +393,23 @@ impl ChannelView { buffer.acknowledge_buffer_version(cx); }); } + + fn get_channel(&self, cx: &App) -> (SharedString, Option) { + if let Some(channel) = self.channel(cx) { + let status = match ( + self.channel_buffer.read(cx).buffer().read(cx).read_only(), + self.channel_buffer.read(cx).is_connected(), + ) { + (false, true) => None, + (true, true) => Some("read-only"), + (_, false) => Some("disconnected"), + }; + + (channel.name.clone(), status.map(Into::into)) + } else { + ("".into(), Some("disconnected".into())) + } + } } impl EventEmitter for ChannelView {} @@ -440,26 +457,21 @@ impl Item for ChannelView { Some(Icon::new(icon)) } - fn tab_content(&self, params: TabContentParams, _: &Window, cx: &App) -> gpui::AnyElement { - let (channel_name, status) = if let Some(channel) = self.channel(cx) { - let status = match ( - self.channel_buffer.read(cx).buffer().read(cx).read_only(), - self.channel_buffer.read(cx).is_connected(), - ) { - (false, true) => None, - (true, true) => Some("read-only"), - (_, false) => Some("disconnected"), - }; - - (channel.name.clone(), status) + fn tab_content_text(&self, _detail: usize, cx: &App) -> SharedString { + let (name, status) = self.get_channel(cx); + if let Some(status) = status { + format!("{name} - {status}").into() } else { - ("".into(), Some("disconnected")) - }; + name + } + } + fn tab_content(&self, params: TabContentParams, _: &Window, cx: &App) -> gpui::AnyElement { + let (name, status) = self.get_channel(cx); h_flex() .gap_2() .child( - Label::new(channel_name) + Label::new(name) .color(params.text_color()) .when(params.preview, |this| this.italic()), ) @@ -540,10 +552,6 @@ impl Item for ChannelView { fn to_item_events(event: &EditorEvent, f: impl FnMut(ItemEvent)) { Editor::to_item_events(event, f) } - - fn tab_content_text(&self, _detail: usize, _cx: &App) -> SharedString { - "Channels".into() - } } impl FollowableItem for ChannelView {