Remove ToggleFollow
internal action
This commit is contained in:
parent
06c01a5937
commit
f881f9e3d8
4 changed files with 31 additions and 57 deletions
|
@ -38,9 +38,7 @@ use std::{
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
use unindent::Unindent as _;
|
use unindent::Unindent as _;
|
||||||
use workspace::{
|
use workspace::{item::ItemHandle as _, shared_screen::SharedScreen, SplitDirection, Workspace};
|
||||||
item::ItemHandle as _, shared_screen::SharedScreen, SplitDirection, ToggleFollow, Workspace,
|
|
||||||
};
|
|
||||||
|
|
||||||
#[ctor::ctor]
|
#[ctor::ctor]
|
||||||
fn init_logger() {
|
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.
|
// When client B starts following client A, all visible view states are replicated to client B.
|
||||||
workspace_b
|
workspace_b
|
||||||
.update(cx_b, |workspace, cx| {
|
.update(cx_b, |workspace, cx| {
|
||||||
workspace
|
workspace.toggle_follow(peer_id_a, cx).unwrap()
|
||||||
.toggle_follow(&ToggleFollow(peer_id_a), cx)
|
|
||||||
.unwrap()
|
|
||||||
})
|
})
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
@ -6158,9 +6154,7 @@ async fn test_basic_following(
|
||||||
// Client C also follows client A.
|
// Client C also follows client A.
|
||||||
workspace_c
|
workspace_c
|
||||||
.update(cx_c, |workspace, cx| {
|
.update(cx_c, |workspace, cx| {
|
||||||
workspace
|
workspace.toggle_follow(peer_id_a, cx).unwrap()
|
||||||
.toggle_follow(&ToggleFollow(peer_id_a), cx)
|
|
||||||
.unwrap()
|
|
||||||
})
|
})
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
@ -6195,7 +6189,7 @@ async fn test_basic_following(
|
||||||
|
|
||||||
// Client C unfollows client A.
|
// Client C unfollows client A.
|
||||||
workspace_c.update(cx_c, |workspace, cx| {
|
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.
|
// 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.
|
// Client C re-follows client A.
|
||||||
workspace_c.update(cx_c, |workspace, cx| {
|
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.
|
// 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.
|
// Client D follows client C.
|
||||||
workspace_d
|
workspace_d
|
||||||
.update(cx_d, |workspace, cx| {
|
.update(cx_d, |workspace, cx| {
|
||||||
workspace
|
workspace.toggle_follow(peer_id_c, cx).unwrap()
|
||||||
.toggle_follow(&ToggleFollow(peer_id_c), cx)
|
|
||||||
.unwrap()
|
|
||||||
})
|
})
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
@ -6434,9 +6426,7 @@ async fn test_basic_following(
|
||||||
// Client A starts following client B.
|
// Client A starts following client B.
|
||||||
workspace_a
|
workspace_a
|
||||||
.update(cx_a, |workspace, cx| {
|
.update(cx_a, |workspace, cx| {
|
||||||
workspace
|
workspace.toggle_follow(peer_id_b, cx).unwrap()
|
||||||
.toggle_follow(&ToggleFollow(peer_id_b), cx)
|
|
||||||
.unwrap()
|
|
||||||
})
|
})
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
@ -6705,9 +6695,7 @@ async fn test_following_tab_order(
|
||||||
//Follow client B as client A
|
//Follow client B as client A
|
||||||
workspace_a
|
workspace_a
|
||||||
.update(cx_a, |workspace, cx| {
|
.update(cx_a, |workspace, cx| {
|
||||||
workspace
|
workspace.toggle_follow(client_b_id, cx).unwrap()
|
||||||
.toggle_follow(&ToggleFollow(client_b_id), cx)
|
|
||||||
.unwrap()
|
|
||||||
})
|
})
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
@ -6822,9 +6810,7 @@ async fn test_peers_following_each_other(
|
||||||
workspace_a
|
workspace_a
|
||||||
.update(cx_a, |workspace, cx| {
|
.update(cx_a, |workspace, cx| {
|
||||||
let leader_id = *project_a.read(cx).collaborators().keys().next().unwrap();
|
let leader_id = *project_a.read(cx).collaborators().keys().next().unwrap();
|
||||||
workspace
|
workspace.toggle_follow(leader_id, cx).unwrap()
|
||||||
.toggle_follow(&workspace::ToggleFollow(leader_id), cx)
|
|
||||||
.unwrap()
|
|
||||||
})
|
})
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
@ -6838,9 +6824,7 @@ async fn test_peers_following_each_other(
|
||||||
workspace_b
|
workspace_b
|
||||||
.update(cx_b, |workspace, cx| {
|
.update(cx_b, |workspace, cx| {
|
||||||
let leader_id = *project_b.read(cx).collaborators().keys().next().unwrap();
|
let leader_id = *project_b.read(cx).collaborators().keys().next().unwrap();
|
||||||
workspace
|
workspace.toggle_follow(leader_id, cx).unwrap()
|
||||||
.toggle_follow(&workspace::ToggleFollow(leader_id), cx)
|
|
||||||
.unwrap()
|
|
||||||
})
|
})
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
@ -6986,9 +6970,7 @@ async fn test_auto_unfollowing(
|
||||||
});
|
});
|
||||||
workspace_b
|
workspace_b
|
||||||
.update(cx_b, |workspace, cx| {
|
.update(cx_b, |workspace, cx| {
|
||||||
workspace
|
workspace.toggle_follow(leader_id, cx).unwrap()
|
||||||
.toggle_follow(&ToggleFollow(leader_id), cx)
|
|
||||||
.unwrap()
|
|
||||||
})
|
})
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
@ -7013,9 +6995,7 @@ async fn test_auto_unfollowing(
|
||||||
|
|
||||||
workspace_b
|
workspace_b
|
||||||
.update(cx_b, |workspace, cx| {
|
.update(cx_b, |workspace, cx| {
|
||||||
workspace
|
workspace.toggle_follow(leader_id, cx).unwrap()
|
||||||
.toggle_follow(&ToggleFollow(leader_id), cx)
|
|
||||||
.unwrap()
|
|
||||||
})
|
})
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
@ -7033,9 +7013,7 @@ async fn test_auto_unfollowing(
|
||||||
|
|
||||||
workspace_b
|
workspace_b
|
||||||
.update(cx_b, |workspace, cx| {
|
.update(cx_b, |workspace, cx| {
|
||||||
workspace
|
workspace.toggle_follow(leader_id, cx).unwrap()
|
||||||
.toggle_follow(&ToggleFollow(leader_id), cx)
|
|
||||||
.unwrap()
|
|
||||||
})
|
})
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
@ -7055,9 +7033,7 @@ async fn test_auto_unfollowing(
|
||||||
|
|
||||||
workspace_b
|
workspace_b
|
||||||
.update(cx_b, |workspace, cx| {
|
.update(cx_b, |workspace, cx| {
|
||||||
workspace
|
workspace.toggle_follow(leader_id, cx).unwrap()
|
||||||
.toggle_follow(&ToggleFollow(leader_id), cx)
|
|
||||||
.unwrap()
|
|
||||||
})
|
})
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
@ -7132,14 +7108,10 @@ async fn test_peers_simultaneously_following_each_other(
|
||||||
});
|
});
|
||||||
|
|
||||||
let a_follow_b = workspace_a.update(cx_a, |workspace, cx| {
|
let a_follow_b = workspace_a.update(cx_a, |workspace, cx| {
|
||||||
workspace
|
workspace.toggle_follow(client_b_id, cx).unwrap()
|
||||||
.toggle_follow(&ToggleFollow(client_b_id), cx)
|
|
||||||
.unwrap()
|
|
||||||
});
|
});
|
||||||
let b_follow_a = workspace_b.update(cx_b, |workspace, cx| {
|
let b_follow_a = workspace_b.update(cx_b, |workspace, cx| {
|
||||||
workspace
|
workspace.toggle_follow(client_a_id, cx).unwrap()
|
||||||
.toggle_follow(&ToggleFollow(client_a_id), cx)
|
|
||||||
.unwrap()
|
|
||||||
});
|
});
|
||||||
|
|
||||||
futures::try_join!(a_follow_b, b_follow_a).unwrap();
|
futures::try_join!(a_follow_b, b_follow_a).unwrap();
|
||||||
|
|
|
@ -23,7 +23,7 @@ use settings::Settings;
|
||||||
use std::{ops::Range, sync::Arc};
|
use std::{ops::Range, sync::Arc};
|
||||||
use theme::{AvatarStyle, Theme};
|
use theme::{AvatarStyle, Theme};
|
||||||
use util::ResultExt;
|
use util::ResultExt;
|
||||||
use workspace::{FollowNextCollaborator, JoinProject, ToggleFollow, Workspace};
|
use workspace::{FollowNextCollaborator, JoinProject, Workspace};
|
||||||
|
|
||||||
actions!(
|
actions!(
|
||||||
collab,
|
collab,
|
||||||
|
@ -746,14 +746,22 @@ impl CollabTitlebarItem {
|
||||||
|
|
||||||
if let Some(location) = location {
|
if let Some(location) = location {
|
||||||
if let Some(replica_id) = replica_id {
|
if let Some(replica_id) = replica_id {
|
||||||
|
enum ToggleFollow {}
|
||||||
|
|
||||||
content = MouseEventHandler::<ToggleFollow, Self>::new(
|
content = MouseEventHandler::<ToggleFollow, Self>::new(
|
||||||
replica_id.into(),
|
replica_id.into(),
|
||||||
cx,
|
cx,
|
||||||
move |_, _| content,
|
move |_, _| content,
|
||||||
)
|
)
|
||||||
.with_cursor_style(CursorStyle::PointingHand)
|
.with_cursor_style(CursorStyle::PointingHand)
|
||||||
.on_click(MouseButton::Left, move |_, _, cx| {
|
.on_click(MouseButton::Left, move |_, item, cx| {
|
||||||
cx.dispatch_action(ToggleFollow(peer_id))
|
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>(
|
.with_tooltip::<ToggleFollow>(
|
||||||
peer_id.as_u64() as usize,
|
peer_id.as_u64() as usize,
|
||||||
|
|
|
@ -15,7 +15,7 @@ use call::ActiveCall;
|
||||||
pub use collab_titlebar_item::{CollabTitlebarItem, ToggleContactsMenu};
|
pub use collab_titlebar_item::{CollabTitlebarItem, ToggleContactsMenu};
|
||||||
use gpui::{actions, AppContext, Task};
|
use gpui::{actions, AppContext, Task};
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use workspace::{AppState, JoinProject, ToggleFollow, Workspace};
|
use workspace::{AppState, JoinProject, Workspace};
|
||||||
|
|
||||||
actions!(collab, [ToggleScreenSharing]);
|
actions!(collab, [ToggleScreenSharing]);
|
||||||
|
|
||||||
|
@ -121,7 +121,7 @@ fn join_project(action: &JoinProject, app_state: Arc<AppState>, cx: &mut AppCont
|
||||||
if let Some(follow_peer_id) = follow_peer_id {
|
if let Some(follow_peer_id) = follow_peer_id {
|
||||||
if !workspace.is_being_followed(follow_peer_id) {
|
if !workspace.is_being_followed(follow_peer_id) {
|
||||||
workspace
|
workspace
|
||||||
.toggle_follow(&ToggleFollow(follow_peer_id), cx)
|
.toggle_follow(follow_peer_id, cx)
|
||||||
.map(|follow| follow.detach_and_log_err(cx));
|
.map(|follow| follow.detach_and_log_err(cx));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -135,9 +135,6 @@ pub struct OpenPaths {
|
||||||
#[derive(Clone, Deserialize, PartialEq)]
|
#[derive(Clone, Deserialize, PartialEq)]
|
||||||
pub struct ActivatePane(pub usize);
|
pub struct ActivatePane(pub usize);
|
||||||
|
|
||||||
#[derive(Clone, PartialEq)]
|
|
||||||
pub struct ToggleFollow(pub PeerId);
|
|
||||||
|
|
||||||
#[derive(Clone, PartialEq)]
|
#[derive(Clone, PartialEq)]
|
||||||
pub struct JoinProject {
|
pub struct JoinProject {
|
||||||
pub project_id: u64,
|
pub project_id: u64,
|
||||||
|
@ -219,7 +216,6 @@ pub type WorkspaceId = i64;
|
||||||
impl_internal_actions!(
|
impl_internal_actions!(
|
||||||
workspace,
|
workspace,
|
||||||
[
|
[
|
||||||
ToggleFollow,
|
|
||||||
JoinProject,
|
JoinProject,
|
||||||
OpenSharedScreen,
|
OpenSharedScreen,
|
||||||
RemoveWorktreeFromProject,
|
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::follow_next_collaborator);
|
||||||
cx.add_async_action(Workspace::close);
|
cx.add_async_action(Workspace::close);
|
||||||
cx.add_global_action(Workspace::close_global);
|
cx.add_global_action(Workspace::close_global);
|
||||||
|
@ -1883,10 +1878,9 @@ impl Workspace {
|
||||||
|
|
||||||
pub fn toggle_follow(
|
pub fn toggle_follow(
|
||||||
&mut self,
|
&mut self,
|
||||||
ToggleFollow(leader_id): &ToggleFollow,
|
leader_id: PeerId,
|
||||||
cx: &mut ViewContext<Self>,
|
cx: &mut ViewContext<Self>,
|
||||||
) -> Option<Task<Result<()>>> {
|
) -> Option<Task<Result<()>>> {
|
||||||
let leader_id = *leader_id;
|
|
||||||
let pane = self.active_pane().clone();
|
let pane = self.active_pane().clone();
|
||||||
|
|
||||||
if let Some(prev_leader_id) = self.unfollow(&pane, cx) {
|
if let Some(prev_leader_id) = self.unfollow(&pane, cx) {
|
||||||
|
@ -1965,7 +1959,7 @@ impl Workspace {
|
||||||
|
|
||||||
next_leader_id
|
next_leader_id
|
||||||
.or_else(|| collaborators.keys().copied().next())
|
.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(
|
pub fn unfollow(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue