mirror of
https://github.com/zed-industries/zed.git
synced 2024-09-20 02:47:34 +03:00
Use AppContext instead of AsyncWindowContext to quit
Fixes refcell-related panic
This commit is contained in:
parent
a71180257d
commit
44876062c9
@ -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()
|
||||
|
@ -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()
|
||||
|
@ -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();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user