diff --git a/crates/collab_ui/src/collab_titlebar_item.rs b/crates/collab_ui/src/collab_titlebar_item.rs index 3351fb9eb9c14c7f82f0f4d27243776a5b419161..ffafa2d142c427614bc87daab65d85a947d92673 100644 --- a/crates/collab_ui/src/collab_titlebar_item.rs +++ b/crates/collab_ui/src/collab_titlebar_item.rs @@ -417,9 +417,13 @@ impl CollabTitlebarItem { theme: &Theme, cx: &mut RenderContext, ) -> ElementBox { - let is_followed = peer.map_or(false, |(peer_id, _, _)| { - workspace.read(cx).is_following(peer_id) + let (is_followed, is_following) = peer.map_or((false, false), |(peer_id, _, _)| { + ( + workspace.read(cx).is_following(peer_id), + workspace.read(cx).is_followed(peer_id), + ) }); + // my color, around their avatar. let mut avatar_style; if let Some((_, _, location)) = peer.as_ref() { @@ -442,6 +446,10 @@ impl CollabTitlebarItem { replica_color = Some(color); if is_followed { avatar_style.border = Border::all(1.0, color); + } else if is_following { + let our_id = workspace.read(cx).project().read(cx).replica_id(); + let our_color = theme.editor.replica_selection_style(our_id).cursor; + avatar_style.border = Border::all(1.0, our_color); } } diff --git a/crates/workspace/src/workspace.rs b/crates/workspace/src/workspace.rs index 58517346097af8b6f79d1fe0bb60b837d037af60..6a8fdaa17b4e54d49d8868e7ebbbc3cdc8e32c21 100644 --- a/crates/workspace/src/workspace.rs +++ b/crates/workspace/src/workspace.rs @@ -1623,6 +1623,7 @@ impl Workspace { project_id, leader_id: Some(leader_id), }); + Some(cx.spawn_weak(|this, mut cx| async move { let response = request.await?; if let Some(this) = this.upgrade(&cx) { @@ -1719,6 +1720,10 @@ impl Workspace { self.follower_states_by_leader.contains_key(&peer_id) } + pub fn is_followed(&self, peer_id: PeerId) -> bool { + self.leader_state.followers.contains(&peer_id) + } + fn render_titlebar(&self, theme: &Theme, cx: &mut RenderContext) -> ElementBox { let project = &self.project.read(cx); let mut worktree_root_names = String::new(); @@ -1896,6 +1901,9 @@ impl Workspace { .to_proto(), ) }); + + cx.notify(); + Ok(proto::FollowResponse { active_view_id, views: this @@ -1928,10 +1936,11 @@ impl Workspace { _: Arc, mut cx: AsyncAppContext, ) -> Result<()> { - this.update(&mut cx, |this, _| { + this.update(&mut cx, |this, cx| { this.leader_state .followers .remove(&envelope.original_sender_id()?); + cx.notify(); Ok(()) }) }