mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-11 05:00:16 +00:00
Fix logic for view to send on Follow (#8549)
Before this we would erronously send no view in some cases. Release Notes: - N/A
This commit is contained in:
parent
6e04c1f924
commit
6a3ac94eea
1 changed files with 17 additions and 5 deletions
|
@ -2781,7 +2781,11 @@ impl Workspace {
|
|||
|
||||
// RPC handlers
|
||||
|
||||
fn active_view_for_follower(&self, cx: &mut ViewContext<Self>) -> Option<proto::View> {
|
||||
fn active_view_for_follower(
|
||||
&self,
|
||||
follower_project_id: Option<u64>,
|
||||
cx: &mut ViewContext<Self>,
|
||||
) -> Option<proto::View> {
|
||||
let item = self.active_item(cx)?;
|
||||
let leader_id = self
|
||||
.pane_for(&*item)
|
||||
|
@ -2791,6 +2795,13 @@ impl Workspace {
|
|||
let id = item_handle.remote_id(&self.app_state.client, cx)?;
|
||||
let variant = item_handle.to_state_proto(cx)?;
|
||||
|
||||
if item_handle.is_project_item(cx)
|
||||
&& (follower_project_id.is_none()
|
||||
|| follower_project_id != self.project.read(cx).remote_id())
|
||||
{
|
||||
return None;
|
||||
}
|
||||
|
||||
Some(proto::View {
|
||||
id: Some(id.to_proto()),
|
||||
leader_id,
|
||||
|
@ -2806,7 +2817,7 @@ impl Workspace {
|
|||
let client = &self.app_state.client;
|
||||
let project_id = self.project.read(cx).remote_id();
|
||||
|
||||
let active_view = self.active_view_for_follower(cx);
|
||||
let active_view = self.active_view_for_follower(follower_project_id, cx);
|
||||
let active_view_id = active_view.as_ref().and_then(|view| view.id.clone());
|
||||
|
||||
cx.notify();
|
||||
|
@ -3981,7 +3992,6 @@ impl WorkspaceStore {
|
|||
project_id: envelope.payload.project_id,
|
||||
peer_id: envelope.original_sender_id()?,
|
||||
};
|
||||
let active_project = ActiveCall::global(cx).read(cx).location().cloned();
|
||||
|
||||
let mut response = proto::FollowResponse::default();
|
||||
this.workspaces.retain(|workspace| {
|
||||
|
@ -3996,14 +4006,16 @@ impl WorkspaceStore {
|
|||
|
||||
if let Some(active_view_id) = handler_response.active_view_id.clone() {
|
||||
if response.active_view_id.is_none()
|
||||
|| Some(workspace.project.downgrade()) == active_project
|
||||
|| workspace.project.read(cx).remote_id() == follower.project_id
|
||||
{
|
||||
response.active_view_id = Some(active_view_id);
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(active_view) = handler_response.active_view.clone() {
|
||||
if workspace.project.read(cx).remote_id() == follower.project_id {
|
||||
if response.active_view_id.is_none()
|
||||
|| workspace.project.read(cx).remote_id() == follower.project_id
|
||||
{
|
||||
response.active_view = Some(active_view)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue