ssh: Dismiss file picker when new window is opened (#19600)

Closes #ISSUE

Release Notes:

- N/A
This commit is contained in:
Piotr Osiewicz 2024-10-23 13:57:50 +02:00 committed by GitHub
parent 7f64f0454d
commit 1bded42b2a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -215,93 +215,94 @@ impl ProjectPicker {
connection.port, connection.port,
&connection.username, &connection.username,
); );
cx.new_view(|cx| { let _path_task = cx
let _path_task = cx .spawn({
.spawn({ let workspace = workspace.clone();
let workspace = workspace.clone(); move |this, mut cx| async move {
move |_, mut cx| async move { let Ok(Some(paths)) = rx.await else {
let Ok(Some(paths)) = rx.await else { workspace
workspace .update(&mut cx, |workspace, cx| {
.update(&mut cx, |workspace, cx| { let weak = cx.view().downgrade();
let weak = cx.view().downgrade(); workspace
workspace .toggle_modal(cx, |cx| RemoteServerProjects::new(cx, weak));
.toggle_modal(cx, |cx| RemoteServerProjects::new(cx, weak)); })
})
.log_err()?;
return None;
};
let app_state = workspace
.update(&mut cx, |workspace, _| workspace.app_state().clone())
.ok()?;
let options = cx
.update(|cx| (app_state.build_window_options)(None, cx))
.log_err()?; .log_err()?;
return None;
};
cx.open_window(options, |cx| { let app_state = workspace
cx.activate_window(); .update(&mut cx, |workspace, _| workspace.app_state().clone())
.ok()?;
let options = cx
.update(|cx| (app_state.build_window_options)(None, cx))
.log_err()?;
let fs = app_state.fs.clone(); cx.open_window(options, |cx| {
update_settings_file::<SshSettings>(fs, cx, { cx.activate_window();
let paths = paths
.iter() let fs = app_state.fs.clone();
.map(|path| path.to_string_lossy().to_string()) update_settings_file::<SshSettings>(fs, cx, {
.collect(); let paths = paths
move |setting, _| { .iter()
if let Some(server) = setting .map(|path| path.to_string_lossy().to_string())
.ssh_connections .collect();
.as_mut() move |setting, _| {
.and_then(|connections| connections.get_mut(ix)) if let Some(server) = setting
{ .ssh_connections
server.projects.push(SshProject { paths }) .as_mut()
} .and_then(|connections| connections.get_mut(ix))
{
server.projects.push(SshProject { paths })
} }
}); }
});
let tasks = paths let tasks = paths
.into_iter() .into_iter()
.map(|path| { .map(|path| {
project.update(cx, |project, cx| { project.update(cx, |project, cx| {
project.find_or_create_worktree(&path, true, cx) project.find_or_create_worktree(&path, true, cx)
})
}) })
.collect::<Vec<_>>();
cx.spawn(|_| async move {
for task in tasks {
task.await?;
}
Ok(())
})
.detach_and_prompt_err(
"Failed to open path",
cx,
|_, _| None,
);
cx.new_view(|cx| {
let workspace =
Workspace::new(None, project.clone(), app_state.clone(), cx);
workspace
.client()
.telemetry()
.report_app_event("create ssh project".to_string());
workspace
}) })
.collect::<Vec<_>>();
cx.spawn(|_| async move {
for task in tasks {
task.await?;
}
Ok(())
}) })
.log_err(); .detach_and_prompt_err(
Some(()) "Failed to open path",
} cx,
}) |_, _| None,
.shared(); );
Self { cx.new_view(|cx| {
_path_task, let workspace =
picker, Workspace::new(None, project.clone(), app_state.clone(), cx);
connection_string,
nickname, workspace
} .client()
.telemetry()
.report_app_event("create ssh project".to_string());
workspace
})
})
.log_err();
this.update(&mut cx, |_, cx| {
cx.emit(DismissEvent);
})
.ok();
Some(())
}
})
.shared();
cx.new_view(|_| Self {
_path_task,
picker,
connection_string,
nickname,
}) })
} }
} }