Remove one todo from the critical path
This commit is contained in:
parent
0ecf6bde73
commit
4da8ee1e1d
2 changed files with 84 additions and 67 deletions
|
@ -1993,6 +1993,23 @@ impl<V: 'static> WindowHandle<V> {
|
||||||
state_type: PhantomData,
|
state_type: PhantomData,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn update<R>(
|
||||||
|
&self,
|
||||||
|
cx: &mut AppContext,
|
||||||
|
update: impl FnOnce(&mut V, &mut ViewContext<V>) -> R,
|
||||||
|
) -> Result<R> {
|
||||||
|
cx.update_window(self.any_handle, |cx| {
|
||||||
|
let root_view = cx
|
||||||
|
.window
|
||||||
|
.root_view
|
||||||
|
.clone()
|
||||||
|
.unwrap()
|
||||||
|
.downcast::<V>()
|
||||||
|
.unwrap();
|
||||||
|
root_view.update(cx, update)
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<V: 'static> Into<AnyWindowHandle> for WindowHandle<V> {
|
impl<V: 'static> Into<AnyWindowHandle> for WindowHandle<V> {
|
||||||
|
|
|
@ -25,7 +25,7 @@ use futures::{
|
||||||
use gpui2::{
|
use gpui2::{
|
||||||
AnyModel, AnyView, AppContext, AsyncAppContext, AsyncWindowContext, DisplayId, Entity,
|
AnyModel, AnyView, AppContext, AsyncAppContext, AsyncWindowContext, DisplayId, Entity,
|
||||||
EventEmitter, MainThread, Model, ModelContext, Subscription, Task, View, ViewContext,
|
EventEmitter, MainThread, Model, ModelContext, Subscription, Task, View, ViewContext,
|
||||||
VisualContext, WeakModel, WeakView, WindowBounds, WindowContext, WindowHandle, WindowOptions,
|
VisualContext, WeakView, WindowBounds, WindowContext, WindowHandle, WindowOptions,
|
||||||
};
|
};
|
||||||
use item::{FollowableItem, FollowableItemHandle, Item, ItemHandle, ProjectItem};
|
use item::{FollowableItem, FollowableItemHandle, Item, ItemHandle, ProjectItem};
|
||||||
use language2::LanguageRegistry;
|
use language2::LanguageRegistry;
|
||||||
|
@ -2812,11 +2812,13 @@ impl Workspace {
|
||||||
|
|
||||||
// // RPC handlers
|
// // RPC handlers
|
||||||
|
|
||||||
// fn handle_follow(
|
fn handle_follow(
|
||||||
// &mut self,
|
&mut self,
|
||||||
// follower_project_id: Option<u64>,
|
follower_project_id: Option<u64>,
|
||||||
// cx: &mut ViewContext<Self>,
|
cx: &mut ViewContext<Self>,
|
||||||
// ) -> proto::FollowResponse {
|
) -> proto::FollowResponse {
|
||||||
|
todo!()
|
||||||
|
|
||||||
// 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();
|
||||||
|
|
||||||
|
@ -2859,7 +2861,7 @@ impl Workspace {
|
||||||
// })
|
// })
|
||||||
// .collect(),
|
// .collect(),
|
||||||
// }
|
// }
|
||||||
// }
|
}
|
||||||
|
|
||||||
fn handle_update_followers(
|
fn handle_update_followers(
|
||||||
&mut self,
|
&mut self,
|
||||||
|
@ -3942,7 +3944,7 @@ impl WorkspaceStore {
|
||||||
.log_err()
|
.log_err()
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn handle_follow(
|
pub async fn handle_follow(
|
||||||
this: Model<Self>,
|
this: Model<Self>,
|
||||||
envelope: TypedEnvelope<proto::Follow>,
|
envelope: TypedEnvelope<proto::Follow>,
|
||||||
_: Arc<Client>,
|
_: Arc<Client>,
|
||||||
|
@ -3953,15 +3955,12 @@ 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();
|
let active_project = ActiveCall::global(cx).read(cx).location().cloned();
|
||||||
|
|
||||||
let mut response = proto::FollowResponse::default();
|
let mut response = proto::FollowResponse::default();
|
||||||
for workspace in &this.workspaces {
|
for workspace in &this.workspaces {
|
||||||
let Some(workspace) = workspace.upgrade(cx) else {
|
workspace
|
||||||
continue;
|
.update(cx, |workspace, cx| {
|
||||||
};
|
|
||||||
|
|
||||||
workspace.update(cx, |workspace, cx| {
|
|
||||||
let handler_response = workspace.handle_follow(follower.project_id, cx);
|
let handler_response = workspace.handle_follow(follower.project_id, cx);
|
||||||
if response.views.is_empty() {
|
if response.views.is_empty() {
|
||||||
response.views = handler_response.views;
|
response.views = handler_response.views;
|
||||||
|
@ -3976,7 +3975,8 @@ impl WorkspaceStore {
|
||||||
response.active_view_id = Some(active_view_id);
|
response.active_view_id = Some(active_view_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
|
.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Err(ix) = this.followers.binary_search(&follower) {
|
if let Err(ix) = this.followers.binary_search(&follower) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue