mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-25 19:29:49 +00:00
Ensure initial project metadata is sent when first sharing a project
This commit is contained in:
parent
4256a96051
commit
5c05b7d413
1 changed files with 17 additions and 13 deletions
|
@ -970,8 +970,6 @@ impl Project {
|
||||||
return Task::ready(Err(anyhow!("project was already shared")));
|
return Task::ready(Err(anyhow!("project was already shared")));
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut worktree_share_tasks = Vec::new();
|
|
||||||
|
|
||||||
for open_buffer in self.opened_buffers.values_mut() {
|
for open_buffer in self.opened_buffers.values_mut() {
|
||||||
match open_buffer {
|
match open_buffer {
|
||||||
OpenBuffer::Strong(_) => {}
|
OpenBuffer::Strong(_) => {}
|
||||||
|
@ -1007,21 +1005,11 @@ impl Project {
|
||||||
.log_err();
|
.log_err();
|
||||||
}
|
}
|
||||||
|
|
||||||
for worktree in self.worktrees(cx).collect::<Vec<_>>() {
|
|
||||||
worktree.update(cx, |worktree, cx| {
|
|
||||||
let worktree = worktree.as_local_mut().unwrap();
|
|
||||||
worktree_share_tasks.push(worktree.share(project_id, cx));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
self.client_subscriptions.push(
|
self.client_subscriptions.push(
|
||||||
self.client
|
self.client
|
||||||
.subscribe_to_entity(project_id)
|
.subscribe_to_entity(project_id)
|
||||||
.set_model(&cx.handle(), &mut cx.to_async()),
|
.set_model(&cx.handle(), &mut cx.to_async()),
|
||||||
);
|
);
|
||||||
let _ = self.metadata_changed(cx);
|
|
||||||
cx.emit(Event::RemoteIdChanged(Some(project_id)));
|
|
||||||
cx.notify();
|
|
||||||
|
|
||||||
let (metadata_changed_tx, mut metadata_changed_rx) = mpsc::unbounded();
|
let (metadata_changed_tx, mut metadata_changed_rx) = mpsc::unbounded();
|
||||||
self.client_state = Some(ProjectClientState::Local {
|
self.client_state = Some(ProjectClientState::Local {
|
||||||
|
@ -1052,7 +1040,23 @@ impl Project {
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
cx.foreground().spawn(async move {
|
let metadata_changed = self.metadata_changed(cx);
|
||||||
|
cx.emit(Event::RemoteIdChanged(Some(project_id)));
|
||||||
|
cx.notify();
|
||||||
|
|
||||||
|
let worktrees = self.worktrees(cx).collect::<Vec<_>>();
|
||||||
|
cx.spawn_weak(|_, mut cx| async move {
|
||||||
|
// Wait for the initial project metadata to be sent before sharing the worktrees.
|
||||||
|
metadata_changed.await;
|
||||||
|
|
||||||
|
let mut worktree_share_tasks = Vec::new();
|
||||||
|
for worktree in worktrees {
|
||||||
|
worktree.update(&mut cx, |worktree, cx| {
|
||||||
|
let worktree = worktree.as_local_mut().unwrap();
|
||||||
|
worktree_share_tasks.push(worktree.share(project_id, cx));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
futures::future::try_join_all(worktree_share_tasks).await?;
|
futures::future::try_join_all(worktree_share_tasks).await?;
|
||||||
Ok(())
|
Ok(())
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue