Set current location after calling another user

This commit is contained in:
Antonio Scandurra 2022-10-08 14:47:40 +02:00
parent 59aaf4ce1b
commit 34cb742db1

View file

@ -825,11 +825,27 @@ impl ContactsPopover {
} }
fn call(&mut self, action: &Call, cx: &mut ViewContext<Self>) { fn call(&mut self, action: &Call, cx: &mut ViewContext<Self>) {
ActiveCall::global(cx) let recipient_user_id = action.recipient_user_id;
.update(cx, |active_call, cx| { let initial_project = action.initial_project.clone();
active_call.invite(action.recipient_user_id, action.initial_project.clone(), cx) let window_id = cx.window_id();
})
.detach_and_log_err(cx); 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);
} }
} }