Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Update chat panel with current channel
Conrad Irwindc158f708f23
diff --git a/crates/call/src/call.rs b/crates/call/src/call.rsindex 87d2e9aa78d..a37cc3bc789 100644--- a/crates/call/src/call.rs+++ b/crates/call/src/call.rs@@ -442,6 +442,8 @@ impl ActiveCall {.location.as_ref().and_then(|location| location.upgrade());+ let channel_id = room.update(cx, |room, cx| room.channel_id());+ cx.emit(Event::RoomJoined { channel_id });room.update(cx, |room, cx| room.set_location(location.as_ref(), cx))}} else {diff --git a/crates/call/src/room.rs b/crates/call/src/room.rsindex 45c6c15fb00..6dae1e6a4d5 100644--- a/crates/call/src/room.rs+++ b/crates/call/src/room.rs@@ -26,6 +26,9 @@ pub const RECONNECT_TIMEOUT: Duration = Duration::from_secs(30);#[derive(Clone, Debug, PartialEq, Eq)]pub enum Event {+ RoomJoined {+ channel_id: Option<u64>,+ },ParticipantLocationChanged {participant_id: proto::PeerId,},diff --git a/crates/collab_ui/src/chat_panel.rs b/crates/collab_ui/src/chat_panel.rsindex 5786ab10d4c..bbe0a6b4fe3 100644--- a/crates/collab_ui/src/chat_panel.rs+++ b/crates/collab_ui/src/chat_panel.rs@@ -1,6 +1,6 @@use crate::{channel_view::ChannelView, is_channels_feature_enabled, ChatPanelSettings};use anyhow::Result;-use call::ActiveCall;+use call::{room, ActiveCall};use channel::{ChannelChat, ChannelChatEvent, ChannelMessageId, ChannelStore};use client::Client;use collections::HashMap;@@ -140,6 +140,18 @@ impl ChatPanel {cx.notify();},));+ this.subscriptions.push(cx.subscribe(+ &ActiveCall::global(cx),+ move |this: &mut Self, _, event: &room::Event, cx| match event {+ room::Event::RoomJoined { channel_id } => {+ if let Some(channel_id) = channel_id {+ this.select_channel(*channel_id, None, cx)+ .detach_and_log_err(cx)+ }+ }+ _ => {}+ },+ ));this})