Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Tear down peer when signing out
Antonio Scandurra9334267bd0f9
diff --git a/crates/client/src/client.rs b/crates/client/src/client.rsindex cbfa9183b5f..79e1e80dce3 100644--- a/crates/client/src/client.rs+++ b/crates/client/src/client.rs@@ -84,7 +84,7 @@ pub fn init(client: Arc<Client>, 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<Self>, cx: &AsyncAppContext) -> Result<()> {- let conn_id = self.connection_id()?;- self.peer.disconnect(conn_id);+ pub fn disconnect(self: &Arc<Self>, cx: &AsyncAppContext) {+ self.peer.teardown();self.set_status(Status::SignedOut, cx);- Ok(())}fn connection_id(&self) -> Result<ConnectionId> {diff --git a/crates/collab/src/tests/integration_tests.rs b/crates/collab/src/tests/integration_tests.rsindex 7c4087f5403..f70fdfb0ba7 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)),