diff --git a/crates/call2/src/call2.rs b/crates/call2/src/call2.rs index 3b821d4bec..df7dd847cf 100644 --- a/crates/call2/src/call2.rs +++ b/crates/call2/src/call2.rs @@ -334,7 +334,7 @@ impl ActiveCall { pub fn join_channel( &mut self, channel_id: u64, - requesting_window: WindowHandle, + requesting_window: Option>, cx: &mut ModelContext, ) -> Task>>> { if let Some(room) = self.room().cloned() { @@ -360,9 +360,9 @@ impl ActiveCall { && room.is_sharing_project() && room.remote_participants().len() > 0 }); - if should_prompt { + if should_prompt && requesting_window.is_some() { return cx.spawn(|this, mut cx| async move { - let answer = requesting_window.update(&mut cx, |_, cx| { + let answer = requesting_window.unwrap().update(&mut cx, |_, cx| { cx.prompt( PromptLevel::Warning, "Leaving this call will unshare your current project.\nDo you want to switch channels?", diff --git a/crates/collab2/src/tests/channel_tests.rs b/crates/collab2/src/tests/channel_tests.rs index 8ce5d99b80..43d18ee7d1 100644 --- a/crates/collab2/src/tests/channel_tests.rs +++ b/crates/collab2/src/tests/channel_tests.rs @@ -364,7 +364,8 @@ async fn test_joining_channel_ancestor_member( let active_call_b = cx_b.read(ActiveCall::global); assert!(active_call_b - .update(cx_b, |active_call, cx| active_call.join_channel(sub_id, cx)) + .update(cx_b, |active_call, cx| active_call + .join_channel(sub_id, None, cx)) .await .is_ok()); } @@ -394,7 +395,9 @@ async fn test_channel_room( let active_call_b = cx_b.read(ActiveCall::global); active_call_a - .update(cx_a, |active_call, cx| active_call.join_channel(zed_id, cx)) + .update(cx_a, |active_call, cx| { + active_call.join_channel(zed_id, None, cx) + }) .await .unwrap(); @@ -442,7 +445,9 @@ async fn test_channel_room( }); active_call_b - .update(cx_b, |active_call, cx| active_call.join_channel(zed_id, cx)) + .update(cx_b, |active_call, cx| { + active_call.join_channel(zed_id, None, cx) + }) .await .unwrap(); @@ -559,12 +564,16 @@ async fn test_channel_room( }); active_call_a - .update(cx_a, |active_call, cx| active_call.join_channel(zed_id, cx)) + .update(cx_a, |active_call, cx| { + active_call.join_channel(zed_id, None, cx) + }) .await .unwrap(); active_call_b - .update(cx_b, |active_call, cx| active_call.join_channel(zed_id, cx)) + .update(cx_b, |active_call, cx| { + active_call.join_channel(zed_id, None, cx) + }) .await .unwrap(); @@ -608,7 +617,9 @@ async fn test_channel_jumping(executor: BackgroundExecutor, cx_a: &mut TestAppCo let active_call_a = cx_a.read(ActiveCall::global); active_call_a - .update(cx_a, |active_call, cx| active_call.join_channel(zed_id, cx)) + .update(cx_a, |active_call, cx| { + active_call.join_channel(zed_id, None, cx) + }) .await .unwrap(); @@ -627,7 +638,7 @@ async fn test_channel_jumping(executor: BackgroundExecutor, cx_a: &mut TestAppCo active_call_a .update(cx_a, |active_call, cx| { - active_call.join_channel(rust_id, cx) + active_call.join_channel(rust_id, None, cx) }) .await .unwrap(); @@ -793,7 +804,7 @@ async fn test_call_from_channel( let active_call_b = cx_b.read(ActiveCall::global); active_call_a - .update(cx_a, |call, cx| call.join_channel(channel_id, cx)) + .update(cx_a, |call, cx| call.join_channel(channel_id, None, cx)) .await .unwrap(); @@ -1286,7 +1297,7 @@ async fn test_guest_access( // Non-members should not be allowed to join assert!(active_call_b - .update(cx_b, |call, cx| call.join_channel(channel_a, cx)) + .update(cx_b, |call, cx| call.join_channel(channel_a, None, cx)) .await .is_err()); @@ -1308,7 +1319,7 @@ async fn test_guest_access( // Client B joins channel A as a guest active_call_b - .update(cx_b, |call, cx| call.join_channel(channel_a, cx)) + .update(cx_b, |call, cx| call.join_channel(channel_a, None, cx)) .await .unwrap(); @@ -1341,7 +1352,7 @@ async fn test_guest_access( assert_channels_list_shape(client_b.channel_store(), cx_b, &[]); active_call_b - .update(cx_b, |call, cx| call.join_channel(channel_b, cx)) + .update(cx_b, |call, cx| call.join_channel(channel_b, None, cx)) .await .unwrap(); @@ -1372,7 +1383,7 @@ async fn test_invite_access( // should not be allowed to join assert!(active_call_b - .update(cx_b, |call, cx| call.join_channel(channel_b_id, cx)) + .update(cx_b, |call, cx| call.join_channel(channel_b_id, None, cx)) .await .is_err()); @@ -1390,7 +1401,7 @@ async fn test_invite_access( .unwrap(); active_call_b - .update(cx_b, |call, cx| call.join_channel(channel_b_id, cx)) + .update(cx_b, |call, cx| call.join_channel(channel_b_id, None, cx)) .await .unwrap(); diff --git a/crates/collab2/src/tests/integration_tests.rs b/crates/collab2/src/tests/integration_tests.rs index f2a39f3511..e579c384e3 100644 --- a/crates/collab2/src/tests/integration_tests.rs +++ b/crates/collab2/src/tests/integration_tests.rs @@ -510,9 +510,10 @@ async fn test_joining_channels_and_calling_multiple_users_simultaneously( // Simultaneously join channel 1 and then channel 2 active_call_a - .update(cx_a, |call, cx| call.join_channel(channel_1, cx)) + .update(cx_a, |call, cx| call.join_channel(channel_1, None, cx)) .detach(); - let join_channel_2 = active_call_a.update(cx_a, |call, cx| call.join_channel(channel_2, cx)); + let join_channel_2 = + active_call_a.update(cx_a, |call, cx| call.join_channel(channel_2, None, cx)); join_channel_2.await.unwrap(); @@ -538,7 +539,8 @@ async fn test_joining_channels_and_calling_multiple_users_simultaneously( call.invite(client_c.user_id().unwrap(), None, cx) }); - let join_channel = active_call_a.update(cx_a, |call, cx| call.join_channel(channel_1, cx)); + let join_channel = + active_call_a.update(cx_a, |call, cx| call.join_channel(channel_1, None, cx)); b_invite.await.unwrap(); c_invite.await.unwrap(); @@ -567,7 +569,8 @@ async fn test_joining_channels_and_calling_multiple_users_simultaneously( .unwrap(); // Simultaneously join channel 1 and call user B and user C from client A. - let join_channel = active_call_a.update(cx_a, |call, cx| call.join_channel(channel_1, cx)); + let join_channel = + active_call_a.update(cx_a, |call, cx| call.join_channel(channel_1, None, cx)); let b_invite = active_call_a.update(cx_a, |call, cx| { call.invite(client_b.user_id().unwrap(), None, cx) diff --git a/crates/collab_ui2/src/collab_panel.rs b/crates/collab_ui2/src/collab_panel.rs index 3c2e78423a..a92389e6bc 100644 --- a/crates/collab_ui2/src/collab_panel.rs +++ b/crates/collab_ui2/src/collab_panel.rs @@ -2510,11 +2510,16 @@ impl CollabPanel { return; }; let active_call = ActiveCall::global(cx); - active_call - .update(cx, |active_call, cx| { - active_call.join_channel(channel_id, handle, cx) - }) - .detach_and_log_err(cx) + cx.spawn(|_, mut cx| async move { + active_call + .update(&mut cx, |active_call, cx| { + active_call.join_channel(channel_id, Some(handle), cx) + }) + .log_err()? + .await + .notify_async_err(&mut cx) + }) + .detach() } // fn join_channel_chat(&mut self, action: &JoinChannelChat, cx: &mut ViewContext) {