Add following into channel notes

co-authored-by: max <max@zed.dev>
This commit is contained in:
Mikayla 2023-08-24 11:25:20 -07:00
parent 7e83138805
commit 199be8241c
No known key found for this signature in database
6 changed files with 128 additions and 17 deletions

View file

@ -674,7 +674,7 @@ pub trait FollowableItem: Item {
fn to_state_proto(&self, cx: &AppContext) -> Option<proto::view::Variant>;
fn from_state_proto(
pane: ViewHandle<Pane>,
project: ModelHandle<Project>,
project: ViewHandle<Workspace>,
id: ViewId,
state: &mut Option<proto::view::Variant>,
cx: &mut AppContext,

View file

@ -345,7 +345,7 @@ pub fn register_project_item<I: ProjectItem>(cx: &mut AppContext) {
type FollowableItemBuilder = fn(
ViewHandle<Pane>,
ModelHandle<Project>,
ViewHandle<Workspace>,
ViewId,
&mut Option<proto::view::Variant>,
&mut AppContext,
@ -362,8 +362,8 @@ pub fn register_followable_item<I: FollowableItem>(cx: &mut AppContext) {
builders.insert(
TypeId::of::<I>(),
(
|pane, project, id, state, cx| {
I::from_state_proto(pane, project, id, state, cx).map(|task| {
|pane, workspace, id, state, cx| {
I::from_state_proto(pane, workspace, id, state, cx).map(|task| {
cx.foreground()
.spawn(async move { Ok(Box::new(task.await?) as Box<_>) })
})
@ -2848,7 +2848,13 @@ impl Workspace {
views: Vec<proto::View>,
cx: &mut AsyncAppContext,
) -> Result<()> {
let project = this.read_with(cx, |this, _| this.project.clone())?;
let this = this
.upgrade(cx)
.ok_or_else(|| anyhow!("workspace dropped"))?;
let project = this
.read_with(cx, |this, _| this.project.clone())
.ok_or_else(|| anyhow!("window dropped"))?;
let replica_id = project
.read_with(cx, |project, _| {
project
@ -2874,12 +2880,11 @@ impl Workspace {
let id = ViewId::from_proto(id.clone())?;
let mut variant = view.variant.clone();
if variant.is_none() {
Err(anyhow!("missing variant"))?;
Err(anyhow!("missing view variant"))?;
}
for build_item in &item_builders {
let task = cx.update(|cx| {
build_item(pane.clone(), project.clone(), id, &mut variant, cx)
});
let task = cx
.update(|cx| build_item(pane.clone(), this.clone(), id, &mut variant, cx));
if let Some(task) = task {
item_tasks.push(task);
leader_view_ids.push(id);
@ -2907,7 +2912,7 @@ impl Workspace {
}
Some(())
})?;
});
}
Ok(())
}