Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Remove `ToggleFollow` internal action
Antonio Scandurraf881f9e3d8a2
diff --git a/crates/collab/src/tests/integration_tests.rs b/crates/collab/src/tests/integration_tests.rsindex 5c192269606..b66b5f6de3e 100644--- a/crates/collab/src/tests/integration_tests.rs+++ b/crates/collab/src/tests/integration_tests.rs@@ -38,9 +38,7 @@ use std::{},};use unindent::Unindent as _;-use workspace::{- item::ItemHandle as _, shared_screen::SharedScreen, SplitDirection, ToggleFollow, Workspace,-};+use workspace::{item::ItemHandle as _, shared_screen::SharedScreen, SplitDirection, Workspace};#[ctor::ctor]fn init_logger() {@@ -6117,9 +6115,7 @@ async fn test_basic_following(// When client B starts following client A, all visible view states are replicated to client B.workspace_b.update(cx_b, |workspace, cx| {- workspace- .toggle_follow(&ToggleFollow(peer_id_a), cx)- .unwrap()+ workspace.toggle_follow(peer_id_a, cx).unwrap()}).await.unwrap();@@ -6158,9 +6154,7 @@ async fn test_basic_following(// Client C also follows client A.workspace_c.update(cx_c, |workspace, cx| {- workspace- .toggle_follow(&ToggleFollow(peer_id_a), cx)- .unwrap()+ workspace.toggle_follow(peer_id_a, cx).unwrap()}).await.unwrap();@@ -6195,7 +6189,7 @@ async fn test_basic_following(// Client C unfollows client A.workspace_c.update(cx_c, |workspace, cx| {- workspace.toggle_follow(&ToggleFollow(peer_id_a), cx);+ workspace.toggle_follow(peer_id_a, cx);});// All clients see that clients B is following client A.@@ -6218,7 +6212,7 @@ async fn test_basic_following(// Client C re-follows client A.workspace_c.update(cx_c, |workspace, cx| {- workspace.toggle_follow(&ToggleFollow(peer_id_a), cx);+ workspace.toggle_follow(peer_id_a, cx);});// All clients see that clients B and C are following client A.@@ -6242,9 +6236,7 @@ async fn test_basic_following(// Client D follows client C.workspace_d.update(cx_d, |workspace, cx| {- workspace- .toggle_follow(&ToggleFollow(peer_id_c), cx)- .unwrap()+ workspace.toggle_follow(peer_id_c, cx).unwrap()}).await.unwrap();@@ -6434,9 +6426,7 @@ async fn test_basic_following(// Client A starts following client B.workspace_a.update(cx_a, |workspace, cx| {- workspace- .toggle_follow(&ToggleFollow(peer_id_b), cx)- .unwrap()+ workspace.toggle_follow(peer_id_b, cx).unwrap()}).await.unwrap();@@ -6705,9 +6695,7 @@ async fn test_following_tab_order(//Follow client B as client Aworkspace_a.update(cx_a, |workspace, cx| {- workspace- .toggle_follow(&ToggleFollow(client_b_id), cx)- .unwrap()+ workspace.toggle_follow(client_b_id, cx).unwrap()}).await.unwrap();@@ -6822,9 +6810,7 @@ async fn test_peers_following_each_other(workspace_a.update(cx_a, |workspace, cx| {let leader_id = *project_a.read(cx).collaborators().keys().next().unwrap();- workspace- .toggle_follow(&workspace::ToggleFollow(leader_id), cx)- .unwrap()+ workspace.toggle_follow(leader_id, cx).unwrap()}).await.unwrap();@@ -6838,9 +6824,7 @@ async fn test_peers_following_each_other(workspace_b.update(cx_b, |workspace, cx| {let leader_id = *project_b.read(cx).collaborators().keys().next().unwrap();- workspace- .toggle_follow(&workspace::ToggleFollow(leader_id), cx)- .unwrap()+ workspace.toggle_follow(leader_id, cx).unwrap()}).await.unwrap();@@ -6986,9 +6970,7 @@ async fn test_auto_unfollowing(});workspace_b.update(cx_b, |workspace, cx| {- workspace- .toggle_follow(&ToggleFollow(leader_id), cx)- .unwrap()+ workspace.toggle_follow(leader_id, cx).unwrap()}).await.unwrap();@@ -7013,9 +6995,7 @@ async fn test_auto_unfollowing(workspace_b.update(cx_b, |workspace, cx| {- workspace- .toggle_follow(&ToggleFollow(leader_id), cx)- .unwrap()+ workspace.toggle_follow(leader_id, cx).unwrap()}).await.unwrap();@@ -7033,9 +7013,7 @@ async fn test_auto_unfollowing(workspace_b.update(cx_b, |workspace, cx| {- workspace- .toggle_follow(&ToggleFollow(leader_id), cx)- .unwrap()+ workspace.toggle_follow(leader_id, cx).unwrap()}).await.unwrap();@@ -7055,9 +7033,7 @@ async fn test_auto_unfollowing(workspace_b.update(cx_b, |workspace, cx| {- workspace- .toggle_follow(&ToggleFollow(leader_id), cx)- .unwrap()+ workspace.toggle_follow(leader_id, cx).unwrap()}).await.unwrap();@@ -7132,14 +7108,10 @@ async fn test_peers_simultaneously_following_each_other(});let a_follow_b = workspace_a.update(cx_a, |workspace, cx| {- workspace- .toggle_follow(&ToggleFollow(client_b_id), cx)- .unwrap()+ workspace.toggle_follow(client_b_id, cx).unwrap()});let b_follow_a = workspace_b.update(cx_b, |workspace, cx| {- workspace- .toggle_follow(&ToggleFollow(client_a_id), cx)- .unwrap()+ workspace.toggle_follow(client_a_id, cx).unwrap()});futures::try_join!(a_follow_b, b_follow_a).unwrap();diff --git a/crates/collab_ui/src/collab_titlebar_item.rs b/crates/collab_ui/src/collab_titlebar_item.rsindex 68b0d36a26c..90bcf999a2a 100644--- a/crates/collab_ui/src/collab_titlebar_item.rs+++ b/crates/collab_ui/src/collab_titlebar_item.rs@@ -23,7 +23,7 @@ use settings::Settings;use std::{ops::Range, sync::Arc};use theme::{AvatarStyle, Theme};use util::ResultExt;-use workspace::{FollowNextCollaborator, JoinProject, ToggleFollow, Workspace};+use workspace::{FollowNextCollaborator, JoinProject, Workspace};actions!(collab,@@ -746,14 +746,22 @@ impl CollabTitlebarItem {if let Some(location) = location {if let Some(replica_id) = replica_id {+ enum ToggleFollow {}+content = MouseEventHandler::<ToggleFollow, Self>::new(replica_id.into(),cx,move |_, _| content,).with_cursor_style(CursorStyle::PointingHand)- .on_click(MouseButton::Left, move |_, _, cx| {- cx.dispatch_action(ToggleFollow(peer_id))+ .on_click(MouseButton::Left, move |_, item, cx| {+ if let Some(workspace) = item.workspace.upgrade(cx) {+ if let Some(task) = workspace+ .update(cx, |workspace, cx| workspace.toggle_follow(peer_id, cx))+ {+ task.detach_and_log_err(cx);+ }+ }}).with_tooltip::<ToggleFollow>(peer_id.as_u64() as usize,diff --git a/crates/collab_ui/src/collab_ui.rs b/crates/collab_ui/src/collab_ui.rsindex 557f9b58d9b..784e398653b 100644--- a/crates/collab_ui/src/collab_ui.rs+++ b/crates/collab_ui/src/collab_ui.rs@@ -15,7 +15,7 @@ use call::ActiveCall;pub use collab_titlebar_item::{CollabTitlebarItem, ToggleContactsMenu};use gpui::{actions, AppContext, Task};use std::sync::Arc;-use workspace::{AppState, JoinProject, ToggleFollow, Workspace};+use workspace::{AppState, JoinProject, Workspace};actions!(collab, [ToggleScreenSharing]);@@ -121,7 +121,7 @@ fn join_project(action: &JoinProject, app_state: Arc<AppState>, cx: &mut AppContif let Some(follow_peer_id) = follow_peer_id {if !workspace.is_being_followed(follow_peer_id) {workspace- .toggle_follow(&ToggleFollow(follow_peer_id), cx)+ .toggle_follow(follow_peer_id, cx).map(|follow| follow.detach_and_log_err(cx));}}diff --git a/crates/workspace/src/workspace.rs b/crates/workspace/src/workspace.rsindex ff2825d1575..43e56d2f24b 100644--- a/crates/workspace/src/workspace.rs+++ b/crates/workspace/src/workspace.rs@@ -135,9 +135,6 @@ pub struct OpenPaths {#[derive(Clone, Deserialize, PartialEq)]pub struct ActivatePane(pub usize);-#[derive(Clone, PartialEq)]-pub struct ToggleFollow(pub PeerId);-#[derive(Clone, PartialEq)]pub struct JoinProject {pub project_id: u64,@@ -219,7 +216,6 @@ pub type WorkspaceId = i64;impl_internal_actions!(workspace,[- ToggleFollow,JoinProject,OpenSharedScreen,RemoveWorktreeFromProject,@@ -298,7 +294,6 @@ pub fn init(app_state: Arc<AppState>, cx: &mut AppContext) {}});- cx.add_async_action(Workspace::toggle_follow);cx.add_async_action(Workspace::follow_next_collaborator);cx.add_async_action(Workspace::close);cx.add_global_action(Workspace::close_global);@@ -1883,10 +1878,9 @@ impl Workspace {pub fn toggle_follow(&mut self,- ToggleFollow(leader_id): &ToggleFollow,+ leader_id: PeerId,cx: &mut ViewContext<Self>,) -> Option<Task<Result<()>>> {- let leader_id = *leader_id;let pane = self.active_pane().clone();if let Some(prev_leader_id) = self.unfollow(&pane, cx) {@@ -1965,7 +1959,7 @@ impl Workspace {next_leader_id.or_else(|| collaborators.keys().copied().next())- .and_then(|leader_id| self.toggle_follow(&ToggleFollow(leader_id), cx))+ .and_then(|leader_id| self.toggle_follow(leader_id, cx))}pub fn unfollow(