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
|
// 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 item = self.active_item(cx)?;
|
||||||
let leader_id = self
|
let leader_id = self
|
||||||
.pane_for(&*item)
|
.pane_for(&*item)
|
||||||
|
@ -2791,6 +2795,13 @@ impl Workspace {
|
||||||
let id = item_handle.remote_id(&self.app_state.client, cx)?;
|
let id = item_handle.remote_id(&self.app_state.client, cx)?;
|
||||||
let variant = item_handle.to_state_proto(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 {
|
Some(proto::View {
|
||||||
id: Some(id.to_proto()),
|
id: Some(id.to_proto()),
|
||||||
leader_id,
|
leader_id,
|
||||||
|
@ -2806,7 +2817,7 @@ impl Workspace {
|
||||||
let client = &self.app_state.client;
|
let client = &self.app_state.client;
|
||||||
let project_id = self.project.read(cx).remote_id();
|
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());
|
let active_view_id = active_view.as_ref().and_then(|view| view.id.clone());
|
||||||
|
|
||||||
cx.notify();
|
cx.notify();
|
||||||
|
@ -3981,7 +3992,6 @@ impl WorkspaceStore {
|
||||||
project_id: envelope.payload.project_id,
|
project_id: envelope.payload.project_id,
|
||||||
peer_id: envelope.original_sender_id()?,
|
peer_id: envelope.original_sender_id()?,
|
||||||
};
|
};
|
||||||
let active_project = ActiveCall::global(cx).read(cx).location().cloned();
|
|
||||||
|
|
||||||
let mut response = proto::FollowResponse::default();
|
let mut response = proto::FollowResponse::default();
|
||||||
this.workspaces.retain(|workspace| {
|
this.workspaces.retain(|workspace| {
|
||||||
|
@ -3996,14 +4006,16 @@ impl WorkspaceStore {
|
||||||
|
|
||||||
if let Some(active_view_id) = handler_response.active_view_id.clone() {
|
if let Some(active_view_id) = handler_response.active_view_id.clone() {
|
||||||
if response.active_view_id.is_none()
|
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);
|
response.active_view_id = Some(active_view_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(active_view) = handler_response.active_view.clone() {
|
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)
|
response.active_view = Some(active_view)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue