From 34cb742db1cbdd24fdb6ac3e67a294b51e42d4a3 Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Sat, 8 Oct 2022 14:47:40 +0200 Subject: [PATCH] Set current location after calling another user --- crates/collab_ui/src/contacts_popover.rs | 26 +++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/crates/collab_ui/src/contacts_popover.rs b/crates/collab_ui/src/contacts_popover.rs index 700c717962..abc8db658b 100644 --- a/crates/collab_ui/src/contacts_popover.rs +++ b/crates/collab_ui/src/contacts_popover.rs @@ -825,11 +825,27 @@ impl ContactsPopover { } fn call(&mut self, action: &Call, cx: &mut ViewContext) { - ActiveCall::global(cx) - .update(cx, |active_call, cx| { - active_call.invite(action.recipient_user_id, action.initial_project.clone(), cx) - }) - .detach_and_log_err(cx); + let recipient_user_id = action.recipient_user_id; + let initial_project = action.initial_project.clone(); + let window_id = cx.window_id(); + + let active_call = ActiveCall::global(cx); + cx.spawn_weak(|_, mut cx| async move { + active_call + .update(&mut cx, |active_call, cx| { + active_call.invite(recipient_user_id, initial_project.clone(), cx) + }) + .await?; + if cx.update(|cx| cx.window_is_active(window_id)) { + active_call + .update(&mut cx, |call, cx| { + call.set_location(initial_project.as_ref(), cx) + }) + .await?; + } + anyhow::Ok(()) + }) + .detach_and_log_err(cx); } }