diff --git a/crates/collab_ui/src/collab_panel.rs b/crates/collab_ui/src/collab_panel.rs index 67ee0cc04b..36782bcdd3 100644 --- a/crates/collab_ui/src/collab_panel.rs +++ b/crates/collab_ui/src/collab_panel.rs @@ -1479,23 +1479,7 @@ impl CollabPanel { }); } } - ListEntry::Channel { channel, .. } => { - let is_active = maybe!({ - let call_channel = ActiveCall::global(cx) - .read(cx) - .room()? - .read(cx) - .channel_id()?; - - Some(call_channel == channel.id) - }) - .unwrap_or(false); - if is_active { - self.open_channel_notes(channel.id, cx) - } else { - self.open_channel(channel.id, cx) - } - } + ListEntry::Channel { channel, .. } => self.open_channel(channel.id, cx), ListEntry::ContactPlaceholder => self.toggle_contact_finder(cx), ListEntry::CallParticipant { user, peer_id, .. } => { if Some(user) == self.user_store.read(cx).current_user().as_ref() { @@ -1977,20 +1961,30 @@ impl CollabPanel { .detach_and_prompt_err("Call failed", cx, |_, _| None); } - fn open_channel(&self, channel_id: u64, cx: &mut ViewContext) { + fn open_channel(&mut self, channel_id: u64, cx: &mut ViewContext) { let Some(workspace) = self.workspace.upgrade() else { return; }; let Some(handle) = cx.window_handle().downcast::() else { return; }; - workspace::open_channel( - channel_id, - workspace.read(cx).app_state().clone(), - Some(handle), - cx, - ) - .detach_and_prompt_err("Failed to join channel", cx, |_, _| None) + let is_in_call = ActiveCall::global(cx) + .read(cx) + .room() + .map(|room| room.read(cx).in_call()) + .unwrap_or(false); + if !is_in_call { + workspace::open_channel( + channel_id, + workspace.read(cx).app_state().clone(), + Some(handle), + cx, + ) + .detach_and_prompt_err("Failed to join channel", cx, |_, _| None); + } + + self.open_channel_notes(channel_id, cx); + self.join_channel_chat(channel_id, cx); } fn join_channel_call(&mut self, _channel_id: ChannelId, cx: &mut ViewContext) { @@ -2590,8 +2584,6 @@ impl CollabPanel { ) .on_click(cx.listener(move |this, _, cx| { this.open_channel(channel_id, cx); - this.open_channel_notes(channel_id, cx); - this.join_channel_chat(channel_id, cx); })) .on_secondary_mouse_down(cx.listener( move |this, event: &MouseDownEvent, cx| { diff --git a/crates/workspace/src/workspace.rs b/crates/workspace/src/workspace.rs index 7562de9094..6723e5c909 100644 --- a/crates/workspace/src/workspace.rs +++ b/crates/workspace/src/workspace.rs @@ -1217,7 +1217,9 @@ impl Workspace { if let Some(active_call) = active_call { if !quitting && workspace_count == 1 - && active_call.read_with(&cx, |call, _| call.room().is_some())? + && active_call.read_with(&cx, |call, cx| { + call.room().is_some_and(|room| room.read(cx).in_call()) + })? { let answer = window.update(&mut cx, |_, cx| { cx.prompt( @@ -1230,12 +1232,11 @@ impl Workspace { if answer.await.log_err() == Some(1) { return anyhow::Ok(false); - } else { - active_call - .update(&mut cx, |call, cx| call.hang_up(cx))? - .await - .log_err(); } + active_call + .update(&mut cx, |call, cx| call.hang_up(cx))? + .await + .log_err(); } }