WIP
This commit is contained in:
parent
fd15551d97
commit
0ecf6bde73
1 changed files with 54 additions and 58 deletions
|
@ -23,9 +23,9 @@ use futures::{
|
||||||
FutureExt,
|
FutureExt,
|
||||||
};
|
};
|
||||||
use gpui2::{
|
use gpui2::{
|
||||||
AnyModel, AnyView, AppContext, AsyncAppContext, AsyncWindowContext, DisplayId, EventEmitter,
|
AnyModel, AnyView, AppContext, AsyncAppContext, AsyncWindowContext, DisplayId, Entity,
|
||||||
MainThread, Model, ModelContext, Subscription, Task, View, ViewContext, VisualContext,
|
EventEmitter, MainThread, Model, ModelContext, Subscription, Task, View, ViewContext,
|
||||||
WeakModel, WeakView, WindowBounds, WindowHandle, WindowOptions,
|
VisualContext, WeakModel, 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;
|
||||||
|
@ -426,7 +426,7 @@ pub struct AppState {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct WorkspaceStore {
|
pub struct WorkspaceStore {
|
||||||
workspaces: HashSet<WeakView<Workspace>>,
|
workspaces: HashSet<WindowHandle<Workspace>>,
|
||||||
followers: Vec<Follower>,
|
followers: Vec<Follower>,
|
||||||
client: Arc<Client>,
|
client: Arc<Client>,
|
||||||
_subscriptions: Vec<client2::Subscription>,
|
_subscriptions: Vec<client2::Subscription>,
|
||||||
|
@ -3023,7 +3023,7 @@ impl Workspace {
|
||||||
&self,
|
&self,
|
||||||
project_only: bool,
|
project_only: bool,
|
||||||
update: proto::update_followers::Variant,
|
update: proto::update_followers::Variant,
|
||||||
cx: &mut AppContext,
|
cx: &mut WindowContext,
|
||||||
) -> Option<()> {
|
) -> Option<()> {
|
||||||
let project_id = if project_only {
|
let project_id = if project_only {
|
||||||
self.project.read(cx).remote_id()
|
self.project.read(cx).remote_id()
|
||||||
|
@ -3895,17 +3895,16 @@ impl EventEmitter for Workspace {
|
||||||
|
|
||||||
impl WorkspaceStore {
|
impl WorkspaceStore {
|
||||||
pub fn new(client: Arc<Client>, cx: &mut ModelContext<Self>) -> Self {
|
pub fn new(client: Arc<Client>, cx: &mut ModelContext<Self>) -> Self {
|
||||||
// Self {
|
Self {
|
||||||
// workspaces: Default::default(),
|
workspaces: Default::default(),
|
||||||
// followers: Default::default(),
|
followers: Default::default(),
|
||||||
// _subscriptions: vec![
|
_subscriptions: vec![],
|
||||||
// client.add_request_handler(cx.weak_model(), Self::handle_follow),
|
// client.add_request_handler(cx.weak_model(), Self::handle_follow),
|
||||||
// client.add_message_handler(cx.weak_model(), Self::handle_unfollow),
|
// client.add_message_handler(cx.weak_model(), Self::handle_unfollow),
|
||||||
// client.add_message_handler(cx.weak_model(), Self::handle_update_followers),
|
// client.add_message_handler(cx.weak_model(), Self::handle_update_followers),
|
||||||
// ],
|
// ],
|
||||||
// client,
|
client,
|
||||||
// }
|
}
|
||||||
todo!()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn update_followers(
|
pub fn update_followers(
|
||||||
|
@ -3943,53 +3942,50 @@ impl WorkspaceStore {
|
||||||
.log_err()
|
.log_err()
|
||||||
}
|
}
|
||||||
|
|
||||||
// async fn handle_follow(
|
async fn handle_follow(
|
||||||
// this: Model<Self>,
|
this: Model<Self>,
|
||||||
// envelope: TypedEnvelope<proto::Follow>,
|
envelope: TypedEnvelope<proto::Follow>,
|
||||||
// _: Arc<Client>,
|
_: Arc<Client>,
|
||||||
// mut cx: AsyncAppContext,
|
mut cx: AsyncAppContext,
|
||||||
// ) -> Result<proto::FollowResponse> {
|
) -> Result<proto::FollowResponse> {
|
||||||
// this.update(&mut cx, |this, cx| {
|
this.update(&mut cx, |this, cx| {
|
||||||
// let follower = Follower {
|
let follower = Follower {
|
||||||
// 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)
|
let active_project = ActiveCall::global(cx).read(cx).location();
|
||||||
// .read(cx)
|
|
||||||
// .location()
|
|
||||||
// .map(|project| project.id());
|
|
||||||
|
|
||||||
// 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 {
|
let Some(workspace) = workspace.upgrade(cx) else {
|
||||||
// continue;
|
continue;
|
||||||
// };
|
};
|
||||||
|
|
||||||
// workspace.update(cx.as_mut(), |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;
|
||||||
// } else {
|
} else {
|
||||||
// response.views.extend_from_slice(&handler_response.views);
|
response.views.extend_from_slice(&handler_response.views);
|
||||||
// }
|
}
|
||||||
|
|
||||||
// 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.id()) == active_project
|
|| Some(workspace.project.downgrade()) == active_project
|
||||||
// {
|
{
|
||||||
// response.active_view_id = Some(active_view_id);
|
response.active_view_id = Some(active_view_id);
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// });
|
});
|
||||||
// }
|
}
|
||||||
|
|
||||||
// if let Err(ix) = this.followers.binary_search(&follower) {
|
if let Err(ix) = this.followers.binary_search(&follower) {
|
||||||
// this.followers.insert(ix, follower);
|
this.followers.insert(ix, follower);
|
||||||
// }
|
}
|
||||||
|
|
||||||
// Ok(response)
|
Ok(response)
|
||||||
// })
|
})?
|
||||||
// }
|
}
|
||||||
|
|
||||||
async fn handle_unfollow(
|
async fn handle_unfollow(
|
||||||
model: Model<Self>,
|
model: Model<Self>,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue