Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Use AppContext instead of AsyncWindowContext to quit
Piotr Osiewicz44876062c958
diff --git a/crates/call2/src/call2.rs b/crates/call2/src/call2.rsindex d983af50b76..534964b3c27 100644--- a/crates/call2/src/call2.rs+++ b/crates/call2/src/call2.rs@@ -609,12 +609,12 @@ impl CallHandler for Call {fn room_id(&self, cx: &AppContext) -> Option<u64> {Some(self.active_call.as_ref()?.0.read(cx).room()?.read(cx).id())}- fn hang_up(&self, mut cx: AsyncWindowContext) -> Result<Task<Result<()>>> {+ fn hang_up(&self, mut cx: &mut AppContext) -> Task<Result<()>> {let Some((call, _)) = self.active_call.as_ref() else {- bail!("Cannot exit a call; not in a call");+ return Task::ready(Err(anyhow!("Cannot exit a call; not in a call")));};- call.update(&mut cx, |this, cx| this.hang_up(cx))+ call.update(cx, |this, cx| this.hang_up(cx))}fn active_project(&self, cx: &AppContext) -> Option<WeakModel<Project>> {ActiveCall::global(cx).read(cx).location().cloned()diff --git a/crates/collab_ui2/src/collab_titlebar_item.rs b/crates/collab_ui2/src/collab_titlebar_item.rsindex a58186d0f0d..bfa2932aee2 100644--- a/crates/collab_ui2/src/collab_titlebar_item.rs+++ b/crates/collab_ui2/src/collab_titlebar_item.rs@@ -230,7 +230,14 @@ impl Render for CollabTitlebarItem {.child(h_stack().child(Button::new(if is_shared { "Unshare" } else { "Share" }))- .child(IconButton::new("leave-call", ui::Icon::Exit)),+ .child(IconButton::new("leave-call", ui::Icon::Exit).on_click({+ let workspace = workspace.clone();+ move |_, cx| {+ workspace.update(cx, |this, cx| {+ this.call_state().hang_up(cx).detach();+ });+ }+ })),).child(h_stack()diff --git a/crates/workspace2/src/workspace2.rs b/crates/workspace2/src/workspace2.rsindex f906a194983..135a7136617 100644--- a/crates/workspace2/src/workspace2.rs+++ b/crates/workspace2/src/workspace2.rs@@ -479,7 +479,7 @@ pub trait CallHandler {fn is_in_room(&self, cx: &mut ViewContext<Workspace>) -> bool {self.room_id(cx).is_some()}- fn hang_up(&self, cx: AsyncWindowContext) -> Result<Task<Result<()>>>;+ fn hang_up(&self, cx: &mut AppContext) -> Task<Result<()>>;fn active_project(&self, cx: &AppContext) -> Option<WeakModel<Project>>;fn invite(&mut self,@@ -1222,7 +1222,7 @@ impl Workspace {if answer.await.log_err() == Some(1) {return anyhow::Ok(false);} else {- this.update(&mut cx, |this, cx| this.call_handler.hang_up(cx.to_async()))??+ this.update(&mut cx, |this, cx| this.call_handler.hang_up(cx))?.await.log_err();}