remote projects: Allow reusing window (#11058)

Release Notes:

- Allow reusing the window when opening a remote project from the recent
projects picker
- Fixed an issue, which would not let you rejoin a remote project after
disconnecting from it for the first time

---------

Co-authored-by: Conrad <conrad@zed.dev>
Co-authored-by: Remco <djsmits12@gmail.com>
This commit is contained in:
Bennet Bo Fenner 2024-04-26 21:04:34 +02:00 committed by GitHub
parent 1af1a9e8b3
commit 314b723292
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 80 additions and 23 deletions

View file

@ -4785,6 +4785,7 @@ pub fn join_hosted_project(
pub fn join_remote_project(
project_id: ProjectId,
app_state: Arc<AppState>,
window_to_replace: Option<WindowHandle<Workspace>>,
cx: &mut AppContext,
) -> Task<Result<WindowHandle<Workspace>>> {
let windows = cx.windows();
@ -4816,16 +4817,25 @@ pub fn join_remote_project(
)
.await?;
let window_bounds_override = window_bounds_env_override();
cx.update(|cx| {
let mut options = (app_state.build_window_options)(None, cx);
options.bounds = window_bounds_override;
cx.open_window(options, |cx| {
cx.new_view(|cx| {
if let Some(window_to_replace) = window_to_replace {
cx.update_window(window_to_replace.into(), |_, cx| {
cx.replace_root_view(|cx| {
Workspace::new(Default::default(), project, app_state.clone(), cx)
});
})?;
window_to_replace
} else {
let window_bounds_override = window_bounds_env_override();
cx.update(|cx| {
let mut options = (app_state.build_window_options)(None, cx);
options.bounds = window_bounds_override;
cx.open_window(options, |cx| {
cx.new_view(|cx| {
Workspace::new(Default::default(), project, app_state.clone(), cx)
})
})
})
})?
})?
}
};
workspace.update(&mut cx, |_, cx| {