From e0db62173aba87cfd2d9eb4245e77501cbb37bf5 Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Thu, 29 Sep 2022 17:24:31 +0200 Subject: [PATCH] Rename `room` crate to `call` Also, rename `client::Call` to `client::IncomingCall`. Co-Authored-By: Nathan Sobo --- Cargo.lock | 30 +++++++++---------- crates/{room => call}/Cargo.toml | 4 +-- .../src/active_call.rs => call/src/call.rs} | 9 ++++-- crates/{room => call}/src/participant.rs | 0 crates/{room => call}/src/room.rs | 10 ++----- crates/client/src/client.rs | 2 +- .../client/src/{call.rs => incoming_call.rs} | 2 +- crates/client/src/user.rs | 11 ++++--- crates/collab/Cargo.toml | 2 +- crates/collab/src/integration_tests.rs | 2 +- crates/collab_ui/Cargo.toml | 6 ++-- crates/collab_ui/src/contacts_popover.rs | 2 +- .../src/incoming_call_notification.rs | 12 +++++--- 13 files changed, 49 insertions(+), 43 deletions(-) rename crates/{room => call}/Cargo.toml (95%) rename crates/{room/src/active_call.rs => call/src/call.rs} (94%) rename crates/{room => call}/src/participant.rs (100%) rename crates/{room => call}/src/room.rs (96%) rename crates/client/src/{call.rs => incoming_call.rs} (84%) diff --git a/Cargo.lock b/Cargo.lock index 655ec8ab03..b3fe2f899b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -684,6 +684,19 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c1db59621ec70f09c5e9b597b220c7a2b43611f4710dc03ceb8748637775692c" +[[package]] +name = "call" +version = "0.1.0" +dependencies = [ + "anyhow", + "client", + "collections", + "futures", + "gpui", + "project", + "util", +] + [[package]] name = "cap-fs-ext" version = "0.24.4" @@ -1019,6 +1032,7 @@ dependencies = [ "axum", "axum-extra", "base64", + "call", "clap 3.2.8", "client", "collections", @@ -1040,7 +1054,6 @@ dependencies = [ "prometheus", "rand 0.8.5", "reqwest", - "room", "rpc", "scrypt", "serde", @@ -1067,6 +1080,7 @@ name = "collab_ui" version = "0.1.0" dependencies = [ "anyhow", + "call", "client", "clock", "collections", @@ -1078,7 +1092,6 @@ dependencies = [ "menu", "postage", "project", - "room", "serde", "settings", "theme", @@ -4452,19 +4465,6 @@ dependencies = [ "librocksdb-sys", ] -[[package]] -name = "room" -version = "0.1.0" -dependencies = [ - "anyhow", - "client", - "collections", - "futures", - "gpui", - "project", - "util", -] - [[package]] name = "roxmltree" version = "0.14.1" diff --git a/crates/room/Cargo.toml b/crates/call/Cargo.toml similarity index 95% rename from crates/room/Cargo.toml rename to crates/call/Cargo.toml index 169f04d352..cf5e7d6702 100644 --- a/crates/room/Cargo.toml +++ b/crates/call/Cargo.toml @@ -1,10 +1,10 @@ [package] -name = "room" +name = "call" version = "0.1.0" edition = "2021" [lib] -path = "src/room.rs" +path = "src/call.rs" doctest = false [features] diff --git a/crates/room/src/active_call.rs b/crates/call/src/call.rs similarity index 94% rename from crates/room/src/active_call.rs rename to crates/call/src/call.rs index de0bc5e639..11dde75697 100644 --- a/crates/room/src/active_call.rs +++ b/crates/call/src/call.rs @@ -1,7 +1,10 @@ -use crate::Room; +mod participant; +mod room; + use anyhow::{anyhow, Result}; -use client::{call::Call, Client, UserStore}; +use client::{incoming_call::IncomingCall, Client, UserStore}; use gpui::{Entity, ModelContext, ModelHandle, MutableAppContext, Task}; +pub use room::Room; use std::sync::Arc; use util::ResultExt; @@ -49,7 +52,7 @@ impl ActiveCall { pub fn join( &mut self, - call: &Call, + call: &IncomingCall, client: &Arc, user_store: &ModelHandle, cx: &mut ModelContext, diff --git a/crates/room/src/participant.rs b/crates/call/src/participant.rs similarity index 100% rename from crates/room/src/participant.rs rename to crates/call/src/participant.rs diff --git a/crates/room/src/room.rs b/crates/call/src/room.rs similarity index 96% rename from crates/room/src/room.rs rename to crates/call/src/room.rs index 229ee69aeb..adf3a676aa 100644 --- a/crates/room/src/room.rs +++ b/crates/call/src/room.rs @@ -1,13 +1,9 @@ -mod active_call; -mod participant; - -pub use active_call::ActiveCall; +use crate::participant::{LocalParticipant, ParticipantLocation, RemoteParticipant}; use anyhow::{anyhow, Result}; -use client::{call::Call, proto, Client, PeerId, TypedEnvelope, User, UserStore}; +use client::{incoming_call::IncomingCall, proto, Client, PeerId, TypedEnvelope, User, UserStore}; use collections::HashMap; use futures::StreamExt; use gpui::{AsyncAppContext, Entity, ModelContext, ModelHandle, MutableAppContext, Task}; -use participant::{LocalParticipant, ParticipantLocation, RemoteParticipant}; use project::Project; use std::sync::Arc; use util::ResultExt; @@ -81,7 +77,7 @@ impl Room { } pub fn join( - call: &Call, + call: &IncomingCall, client: Arc, user_store: ModelHandle, cx: &mut MutableAppContext, diff --git a/crates/client/src/client.rs b/crates/client/src/client.rs index 16f91f0680..9c5b8e35c9 100644 --- a/crates/client/src/client.rs +++ b/crates/client/src/client.rs @@ -1,9 +1,9 @@ #[cfg(any(test, feature = "test-support"))] pub mod test; -pub mod call; pub mod channel; pub mod http; +pub mod incoming_call; pub mod user; use anyhow::{anyhow, Context, Result}; diff --git a/crates/client/src/call.rs b/crates/client/src/incoming_call.rs similarity index 84% rename from crates/client/src/call.rs rename to crates/client/src/incoming_call.rs index 9b7ce06df4..75d8411ec3 100644 --- a/crates/client/src/call.rs +++ b/crates/client/src/incoming_call.rs @@ -2,7 +2,7 @@ use crate::User; use std::sync::Arc; #[derive(Clone)] -pub struct Call { +pub struct IncomingCall { pub room_id: u64, pub caller: Arc, pub participants: Vec>, diff --git a/crates/client/src/user.rs b/crates/client/src/user.rs index d285cb09db..ff5f03d5ef 100644 --- a/crates/client/src/user.rs +++ b/crates/client/src/user.rs @@ -1,5 +1,5 @@ use super::{http::HttpClient, proto, Client, Status, TypedEnvelope}; -use crate::call::Call; +use crate::incoming_call::IncomingCall; use anyhow::{anyhow, Context, Result}; use collections::{hash_map::Entry, BTreeSet, HashMap, HashSet}; use futures::{channel::mpsc, future, AsyncReadExt, Future, StreamExt}; @@ -67,7 +67,10 @@ pub struct UserStore { outgoing_contact_requests: Vec>, pending_contact_requests: HashMap, invite_info: Option, - incoming_call: (watch::Sender>, watch::Receiver>), + incoming_call: ( + watch::Sender>, + watch::Receiver>, + ), client: Weak, http: Arc, _maintain_contacts: Task<()>, @@ -205,7 +208,7 @@ impl UserStore { _: Arc, mut cx: AsyncAppContext, ) -> Result { - let call = Call { + let call = IncomingCall { room_id: envelope.payload.room_id, participants: this .update(&mut cx, |this, cx| { @@ -241,7 +244,7 @@ impl UserStore { self.invite_info.as_ref() } - pub fn incoming_call(&self) -> watch::Receiver> { + pub fn incoming_call(&self) -> watch::Receiver> { self.incoming_call.1.clone() } diff --git a/crates/collab/Cargo.toml b/crates/collab/Cargo.toml index 8603f67557..88c3318416 100644 --- a/crates/collab/Cargo.toml +++ b/crates/collab/Cargo.toml @@ -55,13 +55,13 @@ features = ["runtime-tokio-rustls", "postgres", "time", "uuid"] [dev-dependencies] collections = { path = "../collections", features = ["test-support"] } gpui = { path = "../gpui", features = ["test-support"] } +call = { path = "../call", features = ["test-support"] } client = { path = "../client", features = ["test-support"] } editor = { path = "../editor", features = ["test-support"] } language = { path = "../language", features = ["test-support"] } log = { version = "0.4.16", features = ["kv_unstable_serde"] } lsp = { path = "../lsp", features = ["test-support"] } project = { path = "../project", features = ["test-support"] } -room = { path = "../room", features = ["test-support"] } rpc = { path = "../rpc", features = ["test-support"] } settings = { path = "../settings", features = ["test-support"] } theme = { path = "../theme" } diff --git a/crates/collab/src/integration_tests.rs b/crates/collab/src/integration_tests.rs index bd60893a57..d16bff2f37 100644 --- a/crates/collab/src/integration_tests.rs +++ b/crates/collab/src/integration_tests.rs @@ -5,6 +5,7 @@ use crate::{ }; use ::rpc::Peer; use anyhow::anyhow; +use call::Room; use client::{ self, proto, test::FakeHttpClient, Channel, ChannelDetails, ChannelList, Client, Connection, Credentials, EstablishConnectionError, ProjectMetadata, UserStore, RECEIVE_TIMEOUT, @@ -34,7 +35,6 @@ use project::{ DiagnosticSummary, Project, ProjectPath, ProjectStore, WorktreeId, }; use rand::prelude::*; -use room::Room; use rpc::PeerId; use serde_json::json; use settings::{Formatter, Settings}; diff --git a/crates/collab_ui/Cargo.toml b/crates/collab_ui/Cargo.toml index aa2cdb8628..cf3a78a0b5 100644 --- a/crates/collab_ui/Cargo.toml +++ b/crates/collab_ui/Cargo.toml @@ -9,18 +9,19 @@ doctest = false [features] test-support = [ + "call/test-support", "client/test-support", "collections/test-support", "editor/test-support", "gpui/test-support", "project/test-support", - "room/test-support", "settings/test-support", "util/test-support", "workspace/test-support", ] [dependencies] +call = { path = "../call" } client = { path = "../client" } clock = { path = "../clock" } collections = { path = "../collections" } @@ -29,7 +30,6 @@ fuzzy = { path = "../fuzzy" } gpui = { path = "../gpui" } menu = { path = "../menu" } project = { path = "../project" } -room = { path = "../room" } settings = { path = "../settings" } theme = { path = "../theme" } util = { path = "../util" } @@ -41,12 +41,12 @@ postage = { version = "0.4.1", features = ["futures-traits"] } serde = { version = "1.0", features = ["derive", "rc"] } [dev-dependencies] +call = { path = "../call", features = ["test-support"] } client = { path = "../client", features = ["test-support"] } collections = { path = "../collections", features = ["test-support"] } editor = { path = "../editor", features = ["test-support"] } gpui = { path = "../gpui", features = ["test-support"] } project = { path = "../project", features = ["test-support"] } -room = { path = "../room", features = ["test-support"] } settings = { path = "../settings", features = ["test-support"] } util = { path = "../util", features = ["test-support"] } workspace = { path = "../workspace", features = ["test-support"] } diff --git a/crates/collab_ui/src/contacts_popover.rs b/crates/collab_ui/src/contacts_popover.rs index 15a987d6c2..b728a92198 100644 --- a/crates/collab_ui/src/contacts_popover.rs +++ b/crates/collab_ui/src/contacts_popover.rs @@ -1,5 +1,6 @@ use std::sync::Arc; +use call::ActiveCall; use client::{Client, Contact, User, UserStore}; use editor::{Cancel, Editor}; use fuzzy::{match_strings, StringMatchCandidate}; @@ -9,7 +10,6 @@ use gpui::{ ViewHandle, }; use menu::{Confirm, SelectNext, SelectPrev}; -use room::ActiveCall; use settings::Settings; use theme::IconButton; diff --git a/crates/collab_ui/src/incoming_call_notification.rs b/crates/collab_ui/src/incoming_call_notification.rs index ec959f01ea..d1ea216195 100644 --- a/crates/collab_ui/src/incoming_call_notification.rs +++ b/crates/collab_ui/src/incoming_call_notification.rs @@ -1,6 +1,7 @@ use std::sync::Arc; -use client::{call::Call, Client, UserStore}; +use call::ActiveCall; +use client::{incoming_call::IncomingCall, Client, UserStore}; use futures::StreamExt; use gpui::{ elements::*, @@ -8,7 +9,6 @@ use gpui::{ impl_internal_actions, Entity, ModelHandle, MouseButton, MutableAppContext, RenderContext, View, ViewContext, WindowBounds, WindowKind, WindowOptions, }; -use room::ActiveCall; use settings::Settings; use util::ResultExt; @@ -55,13 +55,17 @@ struct RespondToCall { } pub struct IncomingCallNotification { - call: Call, + call: IncomingCall, client: Arc, user_store: ModelHandle, } impl IncomingCallNotification { - pub fn new(call: Call, client: Arc, user_store: ModelHandle) -> Self { + pub fn new( + call: IncomingCall, + client: Arc, + user_store: ModelHandle, + ) -> Self { Self { call, client,