diff --git a/crates/client/src/client.rs b/crates/client/src/client.rs index cbfa9183b5f7d5c8c78716bd8ce74a4be07473db..79e1e80dce339591e56610de3e4ec20995d03362 100644 --- a/crates/client/src/client.rs +++ b/crates/client/src/client.rs @@ -84,7 +84,7 @@ pub fn init(client: Arc, cx: &mut MutableAppContext) { move |_: &SignOut, cx| { let client = client.clone(); cx.spawn(|cx| async move { - client.set_status(Status::SignedOut, &cx); + client.disconnect(&cx); }) .detach(); } @@ -1162,11 +1162,9 @@ impl Client { }) } - pub fn disconnect(self: &Arc, cx: &AsyncAppContext) -> Result<()> { - let conn_id = self.connection_id()?; - self.peer.disconnect(conn_id); + pub fn disconnect(self: &Arc, cx: &AsyncAppContext) { + self.peer.teardown(); self.set_status(Status::SignedOut, cx); - Ok(()) } fn connection_id(&self) -> Result { diff --git a/crates/collab/src/tests/integration_tests.rs b/crates/collab/src/tests/integration_tests.rs index 7c4087f54036302c589f75ff85bc9a25340be58d..f70fdfb0ba7ef626fb775e38bc6a5f305eaacd76 100644 --- a/crates/collab/src/tests/integration_tests.rs +++ b/crates/collab/src/tests/integration_tests.rs @@ -1083,7 +1083,7 @@ async fn test_calls_on_multiple_connections( assert!(incoming_call_b2.next().await.unwrap().is_none()); // User B disconnects the client that is not on the call. Everything should be fine. - client_b1.disconnect(&cx_b1.to_async()).unwrap(); + client_b1.disconnect(&cx_b1.to_async()); deterministic.advance_clock(RECEIVE_TIMEOUT); client_b1 .authenticate_and_connect(false, &cx_b1.to_async()) @@ -3227,7 +3227,7 @@ async fn test_leaving_project( buffer_b2.read_with(cx_b, |buffer, _| assert_eq!(buffer.text(), "a-contents")); // Drop client B's connection and ensure client A and client C observe client B leaving. - client_b.disconnect(&cx_b.to_async()).unwrap(); + client_b.disconnect(&cx_b.to_async()); deterministic.advance_clock(RECONNECT_TIMEOUT); project_a.read_with(cx_a, |project, _| { assert_eq!(project.collaborators().len(), 1); @@ -5772,7 +5772,7 @@ async fn test_contact_requests( .is_empty()); async fn disconnect_and_reconnect(client: &TestClient, cx: &mut TestAppContext) { - client.disconnect(&cx.to_async()).unwrap(); + client.disconnect(&cx.to_async()); client.clear_contacts(cx).await; client .authenticate_and_connect(false, &cx.to_async()) @@ -6186,7 +6186,7 @@ async fn test_following( ); // Following interrupts when client B disconnects. - client_b.disconnect(&cx_b.to_async()).unwrap(); + client_b.disconnect(&cx_b.to_async()); deterministic.advance_clock(RECONNECT_TIMEOUT); assert_eq!( workspace_a.read_with(cx_a, |workspace, _| workspace.leader_for_pane(&pane_a)),