Fix Clippy warnings in client
crate (#8719)
This PR fixes a number of Clippy warnings in the `client` crate. Release Notes: - N/A
This commit is contained in:
parent
5de7492146
commit
0ac203bde0
3 changed files with 26 additions and 29 deletions
|
@ -27,7 +27,7 @@ use release_channel::{AppVersion, ReleaseChannel};
|
||||||
use rpc::proto::{AnyTypedEnvelope, EntityMessage, EnvelopedMessage, PeerId, RequestMessage};
|
use rpc::proto::{AnyTypedEnvelope, EntityMessage, EnvelopedMessage, PeerId, RequestMessage};
|
||||||
use schemars::JsonSchema;
|
use schemars::JsonSchema;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use serde_json;
|
|
||||||
use settings::{Settings, SettingsStore};
|
use settings::{Settings, SettingsStore};
|
||||||
use std::{
|
use std::{
|
||||||
any::TypeId,
|
any::TypeId,
|
||||||
|
@ -61,7 +61,7 @@ lazy_static! {
|
||||||
pub static ref ZED_APP_PATH: Option<PathBuf> =
|
pub static ref ZED_APP_PATH: Option<PathBuf> =
|
||||||
std::env::var("ZED_APP_PATH").ok().map(PathBuf::from);
|
std::env::var("ZED_APP_PATH").ok().map(PathBuf::from);
|
||||||
pub static ref ZED_ALWAYS_ACTIVE: bool =
|
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);
|
pub const INITIAL_RECONNECTION_DELAY: Duration = Duration::from_millis(100);
|
||||||
|
@ -427,7 +427,7 @@ impl Client {
|
||||||
http: Arc<HttpClientWithUrl>,
|
http: Arc<HttpClientWithUrl>,
|
||||||
cx: &mut AppContext,
|
cx: &mut AppContext,
|
||||||
) -> Arc<Self> {
|
) -> Arc<Self> {
|
||||||
let client = Arc::new(Self {
|
Arc::new(Self {
|
||||||
id: AtomicU64::new(0),
|
id: AtomicU64::new(0),
|
||||||
peer: Peer::new(0),
|
peer: Peer::new(0),
|
||||||
telemetry: Telemetry::new(clock, http.clone(), cx),
|
telemetry: Telemetry::new(clock, http.clone(), cx),
|
||||||
|
@ -438,9 +438,7 @@ impl Client {
|
||||||
authenticate: Default::default(),
|
authenticate: Default::default(),
|
||||||
#[cfg(any(test, feature = "test-support"))]
|
#[cfg(any(test, feature = "test-support"))]
|
||||||
establish_connection: Default::default(),
|
establish_connection: Default::default(),
|
||||||
});
|
})
|
||||||
|
|
||||||
client
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn id(&self) -> u64 {
|
pub fn id(&self) -> u64 {
|
||||||
|
@ -573,10 +571,12 @@ impl Client {
|
||||||
let mut state = self.state.write();
|
let mut state = self.state.write();
|
||||||
if state.entities_by_type_and_remote_id.contains_key(&id) {
|
if state.entities_by_type_and_remote_id.contains_key(&id) {
|
||||||
return Err(anyhow!("already subscribed to entity"));
|
return Err(anyhow!("already subscribed to entity"));
|
||||||
} else {
|
}
|
||||||
|
|
||||||
state
|
state
|
||||||
.entities_by_type_and_remote_id
|
.entities_by_type_and_remote_id
|
||||||
.insert(id, WeakSubscriber::Pending(Default::default()));
|
.insert(id, WeakSubscriber::Pending(Default::default()));
|
||||||
|
|
||||||
Ok(PendingEntitySubscription {
|
Ok(PendingEntitySubscription {
|
||||||
client: self.clone(),
|
client: self.clone(),
|
||||||
remote_id,
|
remote_id,
|
||||||
|
@ -584,7 +584,6 @@ impl Client {
|
||||||
_entity_type: PhantomData,
|
_entity_type: PhantomData,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
pub fn add_message_handler<M, E, H, F>(
|
pub fn add_message_handler<M, E, H, F>(
|
||||||
|
@ -926,7 +925,7 @@ impl Client {
|
||||||
move |cx| async move {
|
move |cx| async move {
|
||||||
match handle_io.await {
|
match handle_io.await {
|
||||||
Ok(()) => {
|
Ok(()) => {
|
||||||
if this.status().borrow().clone()
|
if *this.status().borrow()
|
||||||
== (Status::Connected {
|
== (Status::Connected {
|
||||||
connection_id,
|
connection_id,
|
||||||
peer_id,
|
peer_id,
|
||||||
|
@ -1335,7 +1334,7 @@ impl Client {
|
||||||
pending.push(message);
|
pending.push(message);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Some(weak_subscriber @ _) => match weak_subscriber {
|
Some(weak_subscriber) => match weak_subscriber {
|
||||||
WeakSubscriber::Entity { handle } => {
|
WeakSubscriber::Entity { handle } => {
|
||||||
subscriber = handle.upgrade();
|
subscriber = handle.upgrade();
|
||||||
}
|
}
|
||||||
|
|
|
@ -84,7 +84,7 @@ impl Telemetry {
|
||||||
TelemetrySettings::register(cx);
|
TelemetrySettings::register(cx);
|
||||||
|
|
||||||
let state = Arc::new(Mutex::new(TelemetryState {
|
let state = Arc::new(Mutex::new(TelemetryState {
|
||||||
settings: TelemetrySettings::get_global(cx).clone(),
|
settings: *TelemetrySettings::get_global(cx),
|
||||||
app_metadata: cx.app_metadata(),
|
app_metadata: cx.app_metadata(),
|
||||||
architecture: env::consts::ARCH,
|
architecture: env::consts::ARCH,
|
||||||
release_channel,
|
release_channel,
|
||||||
|
@ -119,7 +119,7 @@ impl Telemetry {
|
||||||
|
|
||||||
move |cx| {
|
move |cx| {
|
||||||
let mut state = state.lock();
|
let mut state = state.lock();
|
||||||
state.settings = TelemetrySettings::get_global(cx).clone();
|
state.settings = *TelemetrySettings::get_global(cx);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.detach();
|
.detach();
|
||||||
|
@ -168,7 +168,7 @@ impl Telemetry {
|
||||||
) {
|
) {
|
||||||
let mut state = self.state.lock();
|
let mut state = self.state.lock();
|
||||||
state.installation_id = installation_id.map(|id| id.into());
|
state.installation_id = installation_id.map(|id| id.into());
|
||||||
state.session_id = Some(session_id.into());
|
state.session_id = Some(session_id);
|
||||||
drop(state);
|
drop(state);
|
||||||
|
|
||||||
let this = self.clone();
|
let this = self.clone();
|
||||||
|
@ -387,13 +387,11 @@ impl Telemetry {
|
||||||
event,
|
event,
|
||||||
});
|
});
|
||||||
|
|
||||||
if state.installation_id.is_some() {
|
if state.installation_id.is_some() && state.events_queue.len() >= state.max_queue_size {
|
||||||
if state.events_queue.len() >= state.max_queue_size {
|
|
||||||
drop(state);
|
drop(state);
|
||||||
self.flush_events();
|
self.flush_events();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
pub fn metrics_id(self: &Arc<Self>) -> Option<Arc<str>> {
|
pub fn metrics_id(self: &Arc<Self>) -> Option<Arc<str>> {
|
||||||
self.state.lock().metrics_id.clone()
|
self.state.lock().metrics_id.clone()
|
||||||
|
@ -433,7 +431,7 @@ impl Telemetry {
|
||||||
json_bytes.clear();
|
json_bytes.clear();
|
||||||
serde_json::to_writer(&mut json_bytes, event)?;
|
serde_json::to_writer(&mut json_bytes, event)?;
|
||||||
file.write_all(&json_bytes)?;
|
file.write_all(&json_bytes)?;
|
||||||
file.write(b"\n")?;
|
file.write_all(b"\n")?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -442,7 +440,7 @@ impl Telemetry {
|
||||||
let request_body = EventRequestBody {
|
let request_body = EventRequestBody {
|
||||||
installation_id: state.installation_id.as_deref().map(Into::into),
|
installation_id: state.installation_id.as_deref().map(Into::into),
|
||||||
session_id: state.session_id.clone(),
|
session_id: state.session_id.clone(),
|
||||||
is_staff: state.is_staff.clone(),
|
is_staff: state.is_staff,
|
||||||
app_version: state
|
app_version: state
|
||||||
.app_metadata
|
.app_metadata
|
||||||
.app_version
|
.app_version
|
||||||
|
|
|
@ -653,7 +653,7 @@ impl UserStore {
|
||||||
let users = response
|
let users = response
|
||||||
.users
|
.users
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|user| User::new(user))
|
.map(User::new)
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
this.update(&mut cx, |this, _| {
|
this.update(&mut cx, |this, _| {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue