Fix Zed cli actions: opening notes and joining calls

This commit is contained in:
Kirill Bulatov
2023-12-21 14:27:13 +02:00
parent ca091f3d34
commit b14c07ca54
2 changed files with 87 additions and 28 deletions
+17 -1
View File
@@ -4023,7 +4023,23 @@ pub fn join_channel(
})
}
pub fn activate_any_workspace_window(cx: &mut AsyncAppContext) -> Option<AnyWindowHandle> {
pub async fn get_any_active_workspace(
app_state: Arc<AppState>,
mut cx: AsyncAppContext,
) -> anyhow::Result<WindowHandle<Workspace>> {
// find an existing workspace to focus and show call controls
let active_window = activate_any_workspace_window(&mut cx);
if active_window.is_none() {
cx.update(|cx| Workspace::new_local(vec![], app_state.clone(), None, cx))?
.await?;
}
activate_any_workspace_window(&mut cx)
.context("could not open zed")?
.downcast::<Workspace>()
.context("could not open zed workspace window")
}
fn activate_any_workspace_window(cx: &mut AsyncAppContext) -> Option<AnyWindowHandle> {
cx.update(|cx| {
for window in cx.windows() {
let is_workspace = window.downcast::<Workspace>().is_some();