Skip to content

Commit

Permalink
Revert "collab tweaks (#7706)"
Browse files Browse the repository at this point in the history
This reverts commit 21d2b5f.
  • Loading branch information
ConradIrwin committed Feb 13, 2024
1 parent 33f713a commit b4d8dd2
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 26 deletions.
46 changes: 27 additions & 19 deletions crates/collab_ui/src/collab_panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1479,7 +1479,23 @@ impl CollabPanel {
});
}
}
ListEntry::Channel { channel, .. } => self.open_channel(channel.id, cx),
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::ContactPlaceholder => self.toggle_contact_finder(cx),
ListEntry::CallParticipant { user, peer_id, .. } => {
if Some(user) == self.user_store.read(cx).current_user().as_ref() {
Expand Down Expand Up @@ -1961,30 +1977,20 @@ impl CollabPanel {
.detach_and_prompt_err("Call failed", cx, |_, _| None);
}

fn open_channel(&mut self, channel_id: u64, cx: &mut ViewContext<Self>) {
fn open_channel(&self, channel_id: u64, cx: &mut ViewContext<Self>) {
let Some(workspace) = self.workspace.upgrade() else {
return;
};
let Some(handle) = cx.window_handle().downcast::<Workspace>() else {
return;
};
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);
workspace::open_channel(
channel_id,
workspace.read(cx).app_state().clone(),
Some(handle),
cx,
)
.detach_and_prompt_err("Failed to join channel", cx, |_, _| None)
}

fn join_channel_call(&mut self, _channel_id: ChannelId, cx: &mut ViewContext<Self>) {
Expand Down Expand Up @@ -2584,6 +2590,8 @@ 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| {
Expand Down
13 changes: 6 additions & 7 deletions crates/workspace/src/workspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1217,9 +1217,7 @@ impl Workspace {
if let Some(active_call) = active_call {
if !quitting
&& workspace_count == 1
&& active_call.read_with(&cx, |call, cx| {
call.room().is_some_and(|room| room.read(cx).in_call())
})?
&& active_call.read_with(&cx, |call, _| call.room().is_some())?
{
let answer = window.update(&mut cx, |_, cx| {
cx.prompt(
Expand All @@ -1232,11 +1230,12 @@ 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();
}
}

Expand Down

0 comments on commit b4d8dd2

Please sign in to comment.