diff --git a/server/src/rpc.rs b/server/src/rpc.rs index 34f5f378d9..7562bdf74b 100644 --- a/server/src/rpc.rs +++ b/server/src/rpc.rs @@ -1714,7 +1714,7 @@ mod tests { ) .detach(); client - .add_connection(user_id.to_proto(), client_conn, &cx.to_async()) + .set_connection(user_id.to_proto(), client_conn, &cx.to_async()) .await .unwrap(); (user_id, client) diff --git a/zed/src/channel.rs b/zed/src/channel.rs index 24997d4964..38329c70d4 100644 --- a/zed/src/channel.rs +++ b/zed/src/channel.rs @@ -90,18 +90,15 @@ impl ChannelList { let _task = cx.spawn(|this, mut cx| { let rpc = rpc.clone(); async move { - let mut user_id = rpc.user_id(); + let mut status = rpc.status(); loop { - let available_channels = if user_id.recv().await.unwrap().is_some() { - Some( - rpc.request(proto::GetChannels {}) - .await - .context("failed to fetch available channels")? - .channels - .into_iter() - .map(Into::into) - .collect(), - ) + let status = status.recv().await.unwrap(); + let available_channels = if matches!(status, rpc::Status::Connected { .. }) { + let response = rpc + .request(proto::GetChannels {}) + .await + .context("failed to fetch available channels")?; + Some(response.channels.into_iter().map(Into::into).collect()) } else { None }; @@ -671,7 +668,7 @@ mod tests { cx.background().spawn(io).detach(); client - .add_connection(user_id, client_conn, &cx.to_async()) + .set_connection(user_id, client_conn, &cx.to_async()) .await .unwrap(); diff --git a/zed/src/chat_panel.rs b/zed/src/chat_panel.rs index 18b737b2d8..ab38f64169 100644 --- a/zed/src/chat_panel.rs +++ b/zed/src/chat_panel.rs @@ -3,7 +3,7 @@ use std::sync::Arc; use crate::{ channel::{Channel, ChannelEvent, ChannelList, ChannelMessage}, editor::Editor, - rpc::Client, + rpc::{self, Client}, theme, util::{ResultExt, TryFutureExt}, Settings, @@ -14,10 +14,10 @@ use gpui::{ keymap::Binding, platform::CursorStyle, views::{ItemType, Select, SelectStyle}, - AppContext, Entity, ModelHandle, MutableAppContext, RenderContext, Subscription, View, + AppContext, Entity, ModelHandle, MutableAppContext, RenderContext, Subscription, Task, View, ViewContext, ViewHandle, }; -use postage::watch; +use postage::{prelude::Stream, watch}; use time::{OffsetDateTime, UtcOffset}; const MESSAGE_LOADING_THRESHOLD: usize = 50; @@ -31,6 +31,7 @@ pub struct ChatPanel { channel_select: ViewHandle