Fix project subscription order (#8900)
Co-Authored-By: Antonio <as-cii@zed.dev> Release Notes: - Fixed a bug that prevents project joining Co-authored-by: Antonio <as-cii@zed.dev>
This commit is contained in:
parent
9e66d48ccd
commit
d112bcfadf
1 changed files with 39 additions and 27 deletions
|
@ -11,7 +11,10 @@ mod project_tests;
|
||||||
|
|
||||||
use anyhow::{anyhow, bail, Context as _, Result};
|
use anyhow::{anyhow, bail, Context as _, Result};
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use client::{proto, Client, Collaborator, HostedProjectId, TypedEnvelope, UserStore};
|
use client::{
|
||||||
|
proto, Client, Collaborator, HostedProjectId, PendingEntitySubscription, TypedEnvelope,
|
||||||
|
UserStore,
|
||||||
|
};
|
||||||
use clock::ReplicaId;
|
use clock::ReplicaId;
|
||||||
use collections::{hash_map, BTreeMap, HashMap, HashSet, VecDeque};
|
use collections::{hash_map, BTreeMap, HashMap, HashSet, VecDeque};
|
||||||
use copilot::Copilot;
|
use copilot::Copilot;
|
||||||
|
@ -622,17 +625,26 @@ impl Project {
|
||||||
) -> Result<Model<Self>> {
|
) -> Result<Model<Self>> {
|
||||||
client.authenticate_and_connect(true, &cx).await?;
|
client.authenticate_and_connect(true, &cx).await?;
|
||||||
|
|
||||||
|
let subscription = client.subscribe_to_entity(remote_id)?;
|
||||||
let response = client
|
let response = client
|
||||||
.request_envelope(proto::JoinProject {
|
.request_envelope(proto::JoinProject {
|
||||||
project_id: remote_id,
|
project_id: remote_id,
|
||||||
})
|
})
|
||||||
.await?;
|
.await?;
|
||||||
Self::from_join_project_response(response, None, client, user_store, languages, fs, cx)
|
Self::from_join_project_response(
|
||||||
.await
|
response,
|
||||||
|
subscription,
|
||||||
|
client,
|
||||||
|
user_store,
|
||||||
|
languages,
|
||||||
|
fs,
|
||||||
|
cx,
|
||||||
|
)
|
||||||
|
.await
|
||||||
}
|
}
|
||||||
async fn from_join_project_response(
|
async fn from_join_project_response(
|
||||||
response: TypedEnvelope<proto::JoinProjectResponse>,
|
response: TypedEnvelope<proto::JoinProjectResponse>,
|
||||||
hosted_project_id: Option<HostedProjectId>,
|
subscription: PendingEntitySubscription<Project>,
|
||||||
client: Arc<Client>,
|
client: Arc<Client>,
|
||||||
user_store: Model<UserStore>,
|
user_store: Model<UserStore>,
|
||||||
languages: Arc<LanguageRegistry>,
|
languages: Arc<LanguageRegistry>,
|
||||||
|
@ -641,7 +653,6 @@ impl Project {
|
||||||
) -> Result<Model<Self>> {
|
) -> Result<Model<Self>> {
|
||||||
let remote_id = response.payload.project_id;
|
let remote_id = response.payload.project_id;
|
||||||
let role = response.payload.role();
|
let role = response.payload.role();
|
||||||
let subscription = client.subscribe_to_entity(remote_id)?;
|
|
||||||
let this = cx.new_model(|cx| {
|
let this = cx.new_model(|cx| {
|
||||||
let replica_id = response.payload.replica_id as ReplicaId;
|
let replica_id = response.payload.replica_id as ReplicaId;
|
||||||
let tasks = Inventory::new(cx);
|
let tasks = Inventory::new(cx);
|
||||||
|
@ -730,7 +741,7 @@ impl Project {
|
||||||
prettiers_per_worktree: HashMap::default(),
|
prettiers_per_worktree: HashMap::default(),
|
||||||
prettier_instances: HashMap::default(),
|
prettier_instances: HashMap::default(),
|
||||||
tasks,
|
tasks,
|
||||||
hosted_project_id,
|
hosted_project_id: None,
|
||||||
};
|
};
|
||||||
this.set_role(role, cx);
|
this.set_role(role, cx);
|
||||||
for worktree in worktrees {
|
for worktree in worktrees {
|
||||||
|
@ -760,28 +771,29 @@ impl Project {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn hosted(
|
pub async fn hosted(
|
||||||
hosted_project_id: HostedProjectId,
|
_hosted_project_id: HostedProjectId,
|
||||||
user_store: Model<UserStore>,
|
_user_store: Model<UserStore>,
|
||||||
client: Arc<Client>,
|
_client: Arc<Client>,
|
||||||
languages: Arc<LanguageRegistry>,
|
_languages: Arc<LanguageRegistry>,
|
||||||
fs: Arc<dyn Fs>,
|
_fs: Arc<dyn Fs>,
|
||||||
cx: AsyncAppContext,
|
_cx: AsyncAppContext,
|
||||||
) -> Result<Model<Self>> {
|
) -> Result<Model<Self>> {
|
||||||
let response = client
|
// let response = client
|
||||||
.request_envelope(proto::JoinHostedProject {
|
// .request_envelope(proto::JoinHostedProject {
|
||||||
id: hosted_project_id.0,
|
// id: hosted_project_id.0,
|
||||||
})
|
// })
|
||||||
.await?;
|
// .await?;
|
||||||
Self::from_join_project_response(
|
// Self::from_join_project_response(
|
||||||
response,
|
// response,
|
||||||
Some(hosted_project_id),
|
// Some(hosted_project_id),
|
||||||
client,
|
// client,
|
||||||
user_store,
|
// user_store,
|
||||||
languages,
|
// languages,
|
||||||
fs,
|
// fs,
|
||||||
cx,
|
// cx,
|
||||||
)
|
// )
|
||||||
.await
|
// .await
|
||||||
|
Err(anyhow!("disabled"))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn release(&mut self, cx: &mut AppContext) {
|
fn release(&mut self, cx: &mut AppContext) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue