mirror of
https://github.com/zed-industries/zed.git
synced 2024-12-28 03:25:59 +00:00
Fix tests, notify errors
This commit is contained in:
parent
af3fa4ec0b
commit
4c2348eb53
4 changed files with 44 additions and 25 deletions
|
@ -334,7 +334,7 @@ impl ActiveCall {
|
|||
pub fn join_channel(
|
||||
&mut self,
|
||||
channel_id: u64,
|
||||
requesting_window: WindowHandle<Workspace>,
|
||||
requesting_window: Option<WindowHandle<Workspace>>,
|
||||
cx: &mut ModelContext<Self>,
|
||||
) -> Task<Result<Option<Model<Room>>>> {
|
||||
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?",
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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<Self>) {
|
||||
|
|
Loading…
Reference in a new issue