diff --git a/crates/client/src/client.rs b/crates/client/src/client.rs index 57d59fa041..0f60f439d0 100644 --- a/crates/client/src/client.rs +++ b/crates/client/src/client.rs @@ -27,7 +27,7 @@ use release_channel::{AppVersion, ReleaseChannel}; use rpc::proto::{AnyTypedEnvelope, EntityMessage, EnvelopedMessage, PeerId, RequestMessage}; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; -use serde_json; + use settings::{Settings, SettingsStore}; use std::{ any::TypeId, @@ -61,7 +61,7 @@ lazy_static! { pub static ref ZED_APP_PATH: Option = std::env::var("ZED_APP_PATH").ok().map(PathBuf::from); pub static ref ZED_ALWAYS_ACTIVE: bool = - std::env::var("ZED_ALWAYS_ACTIVE").map_or(false, |e| e.len() > 0); + std::env::var("ZED_ALWAYS_ACTIVE").map_or(false, |e| !e.is_empty()); } pub const INITIAL_RECONNECTION_DELAY: Duration = Duration::from_millis(100); @@ -427,7 +427,7 @@ impl Client { http: Arc, cx: &mut AppContext, ) -> Arc { - let client = Arc::new(Self { + Arc::new(Self { id: AtomicU64::new(0), peer: Peer::new(0), telemetry: Telemetry::new(clock, http.clone(), cx), @@ -438,9 +438,7 @@ impl Client { authenticate: Default::default(), #[cfg(any(test, feature = "test-support"))] establish_connection: Default::default(), - }); - - client + }) } pub fn id(&self) -> u64 { @@ -573,17 +571,18 @@ impl Client { let mut state = self.state.write(); if state.entities_by_type_and_remote_id.contains_key(&id) { return Err(anyhow!("already subscribed to entity")); - } else { - state - .entities_by_type_and_remote_id - .insert(id, WeakSubscriber::Pending(Default::default())); - Ok(PendingEntitySubscription { - client: self.clone(), - remote_id, - consumed: false, - _entity_type: PhantomData, - }) } + + state + .entities_by_type_and_remote_id + .insert(id, WeakSubscriber::Pending(Default::default())); + + Ok(PendingEntitySubscription { + client: self.clone(), + remote_id, + consumed: false, + _entity_type: PhantomData, + }) } #[track_caller] @@ -926,7 +925,7 @@ impl Client { move |cx| async move { match handle_io.await { Ok(()) => { - if this.status().borrow().clone() + if *this.status().borrow() == (Status::Connected { connection_id, peer_id, @@ -1335,7 +1334,7 @@ impl Client { pending.push(message); return; } - Some(weak_subscriber @ _) => match weak_subscriber { + Some(weak_subscriber) => match weak_subscriber { WeakSubscriber::Entity { handle } => { subscriber = handle.upgrade(); } diff --git a/crates/client/src/telemetry.rs b/crates/client/src/telemetry.rs index 946e5da407..475da1658c 100644 --- a/crates/client/src/telemetry.rs +++ b/crates/client/src/telemetry.rs @@ -84,7 +84,7 @@ impl Telemetry { TelemetrySettings::register(cx); let state = Arc::new(Mutex::new(TelemetryState { - settings: TelemetrySettings::get_global(cx).clone(), + settings: *TelemetrySettings::get_global(cx), app_metadata: cx.app_metadata(), architecture: env::consts::ARCH, release_channel, @@ -119,7 +119,7 @@ impl Telemetry { move |cx| { let mut state = state.lock(); - state.settings = TelemetrySettings::get_global(cx).clone(); + state.settings = *TelemetrySettings::get_global(cx); } }) .detach(); @@ -168,7 +168,7 @@ impl Telemetry { ) { let mut state = self.state.lock(); state.installation_id = installation_id.map(|id| id.into()); - state.session_id = Some(session_id.into()); + state.session_id = Some(session_id); drop(state); let this = self.clone(); @@ -387,11 +387,9 @@ impl Telemetry { event, }); - if state.installation_id.is_some() { - if state.events_queue.len() >= state.max_queue_size { - drop(state); - self.flush_events(); - } + if state.installation_id.is_some() && state.events_queue.len() >= state.max_queue_size { + drop(state); + self.flush_events(); } } @@ -433,7 +431,7 @@ impl Telemetry { json_bytes.clear(); serde_json::to_writer(&mut json_bytes, event)?; file.write_all(&json_bytes)?; - file.write(b"\n")?; + file.write_all(b"\n")?; } } @@ -442,7 +440,7 @@ impl Telemetry { let request_body = EventRequestBody { installation_id: state.installation_id.as_deref().map(Into::into), session_id: state.session_id.clone(), - is_staff: state.is_staff.clone(), + is_staff: state.is_staff, app_version: state .app_metadata .app_version diff --git a/crates/client/src/user.rs b/crates/client/src/user.rs index 7a45ddb8f9..9b7ef1dbb1 100644 --- a/crates/client/src/user.rs +++ b/crates/client/src/user.rs @@ -653,7 +653,7 @@ impl UserStore { let users = response .users .into_iter() - .map(|user| User::new(user)) + .map(User::new) .collect::>(); this.update(&mut cx, |this, _| {