chore: clippy

This commit is contained in:
Vukašin Vojinović 2026-02-19 18:33:47 +01:00 committed by Michael Murphy
parent 6e022755f1
commit 787c5ed49f
14 changed files with 218 additions and 243 deletions

View file

@ -41,15 +41,15 @@ pub fn import_theme(path: &Path) -> color_eyre::Result<()> {
let mut manager = Manager::default();
if manager.mode().is_dark != is_dark {
if let Err(err) = manager.dark_mode(is_dark) {
if manager.mode().is_dark != is_dark
&& let Err(err) = manager.dark_mode(is_dark)
{
return Err(color_eyre::eyre::eyre!(
"Failed to set {} mode: {:?}",
mode_str,
err
));
}
}
manager
.selected_customizer_mut()

View file

@ -536,7 +536,7 @@ impl Page {
Message::Daytime(day_time) => {
self.day_time = day_time;
return Task::none();
},
}
Message::ThemeModeUpdate(mode) => {
let was_dark = self.theme_manager.mode().is_dark;

View file

@ -189,7 +189,7 @@ impl Page {
}
Message::ReplaceApply => {
if let Some((mut binding, ..)) = self.replace_dialog.pop() {
if let Some((binding, ..)) = self.replace_dialog.pop() {
self.add_shortcut(binding, true);
if self.replace_dialog.is_empty() {

View file

@ -846,7 +846,7 @@ impl Page {
)
.collect()
.then(|id| {
if id.get(0).is_some_and(|id| *id == SECURE_INPUT_VPN.clone()) {
if id.first().is_some_and(|id| *id == SECURE_INPUT_VPN.clone()) {
Task::none()
} else {
focus(SECURE_INPUT_VPN.clone())

View file

@ -371,7 +371,7 @@ impl Page {
ssid,
network_type,
_tx,
interface,
_interface,
) => {
if success || matches!(network_type, NetworkType::Open) {
self.connecting.remove(ssid.as_ref());
@ -747,7 +747,10 @@ impl Page {
)
.collect()
.then(|id| {
if id.get(0).is_some_and(|id| *id == SECURE_INPUT_WIFI.clone()) {
if id
.first()
.is_some_and(|id| *id == SECURE_INPUT_WIFI.clone())
{
Task::none()
} else {
focus(SECURE_INPUT_WIFI.clone())

View file

@ -34,7 +34,7 @@ use pipewire::{
proxy::{ProxyListener, ProxyT},
types::ObjectType,
};
use std::{cell::RefCell, rc::Rc, u32};
use std::{cell::RefCell, rc::Rc};
pub type NodeId = u32;
pub type RouteId = u32;
@ -181,12 +181,12 @@ fn run_service(
return;
}
if let Some(device) = Device::from_device(info) {
if let Some(state) = state.upgrade() {
if let Some(device) = Device::from_device(info)
&& let Some(state) = state.upgrade()
{
state.borrow_mut().add_device(pw_id, device);
}
}
}
})
.param({
let state = Rc::downgrade(&state);
@ -281,12 +281,12 @@ fn run_service(
.info({
let state = Rc::downgrade(&state);
move |info| {
if let Some(node) = Node::from_node(info) {
if let Some(state) = state.upgrade() {
if let Some(node) = Node::from_node(info)
&& let Some(state) = state.upgrade()
{
state.borrow_mut().add_node(id, node);
}
}
}
})
.param({
let state = Rc::downgrade(&state);
@ -357,24 +357,18 @@ fn run_service(
"default.audio.sink" => {
if let Ok(value) =
serde_json::de::from_str::<DefaultAudio>(value)
&& let Some(state) = state.upgrade()
{
if let Some(state) = state.upgrade() {
state
.borrow_mut()
.default_sink(value.name.to_owned())
}
state.borrow_mut().default_sink(value.name.to_owned())
}
}
"default.audio.source" => {
if let Ok(value) =
serde_json::de::from_str::<DefaultAudio>(value)
&& let Some(state) = state.upgrade()
{
if let Some(state) = state.upgrade() {
state
.borrow_mut()
.default_source(value.name.to_owned())
}
state.borrow_mut().default_source(value.name.to_owned())
}
}
@ -530,7 +524,7 @@ impl State {
if routes.len() < index as usize + 1 {
let additional = (index as usize + 1) - routes.capacity();
routes.reserve_exact(additional);
routes.extend(std::iter::repeat(Route::default()).take(additional));
routes.extend(std::iter::repeat_n(Route::default(), additional));
}
routes[index as usize] = route.clone();
@ -586,7 +580,7 @@ impl State {
if routes.len() < index as usize + 1 {
let additional = (index as usize + 1) - routes.capacity();
routes.reserve_exact(additional);
routes.extend(std::iter::repeat(Route::default()).take(additional));
routes.extend(std::iter::repeat_n(Route::default(), additional));
}
routes[index as usize] = route.clone();
@ -769,7 +763,6 @@ impl State {
if let Some(param) = Pod::from_bytes(&serialized) {
device.set_param(ParamType::Route, 0, param);
}
return;
}
fn set_node_props(&mut self, id: NodeId, props: NodeProps) {
@ -817,7 +810,7 @@ impl State {
FormatProperties(libspa_sys::SPA_PROP_channelVolumes),
ValueArray,
pod::ValueArray::Float(volume::to_channel_volumes(
&props.channel_map.as_deref().unwrap_or_default(),
props.channel_map.as_deref().unwrap_or_default(),
volume,
balance,
))
@ -887,7 +880,7 @@ impl State {
ValueArray,
pod::ValueArray::Float(if matches!(route.direction, Direction::Output) {
volume::to_channel_volumes(
&props.channel_map.as_deref().unwrap_or_default(),
props.channel_map.as_deref().unwrap_or_default(),
volume,
balance,
)

View file

@ -14,12 +14,10 @@ pub fn string_from_pod(pod: &Pod) -> Option<String> {
unsafe {
// SAFETY: Pod is checked to be a string beforehand
if libspa_sys::spa_pod_get_string(pod.as_raw_ptr(), &mut cstr) == 0 {
if !cstr.is_null() {
if libspa_sys::spa_pod_get_string(pod.as_raw_ptr(), &mut cstr) == 0 && !cstr.is_null() {
return Some(String::from_utf8_lossy(CStr::from_ptr(cstr).to_bytes()).into_owned());
}
}
}
None
}

View file

@ -210,8 +210,9 @@ fn load_thumbnail(
cache_dir: Option<&Path>,
path: &Path,
) -> Option<ImageOperation> {
if let Some(cache_dir) = cache_dir {
if let Ok(ctime) = path.metadata().and_then(|meta| meta.created()) {
if let Some(cache_dir) = cache_dir
&& let Ok(ctime) = path.metadata().and_then(|meta| meta.created())
{
// Search for thumbnail by a unique hash string.
let mut hasher = DefaultHasher::new();
path.hash(&mut hasher);
@ -233,7 +234,6 @@ fn load_thumbnail(
image: open_image(input_buffer, path)?,
});
}
}
if let Some(image) = open_image(input_buffer, path) {
return Some(ImageOperation::GenerateThumbnail { path: None, image });
@ -396,7 +396,7 @@ fn border_radius(
p += (2 * x + 2) as i32;
} else {
// draw when moving to next pixel in y-direction
if y % 16 == 0 {
if y.is_multiple_of(16) {
draw(img, alpha, x / 16, y / 16);
draw(img, alpha, y / 16, x / 16);
skip_draw = true;

View file

@ -57,11 +57,11 @@ impl State {
};
let (tx, rx) = tokio::sync::mpsc::unbounded_channel();
let mut enabled = false;
if let Ok(proxy) = StatusProxy::new(&conn).await {
if let Ok(status) = proxy.screen_reader_enabled().await {
if let Ok(proxy) = StatusProxy::new(&conn).await
&& let Ok(status) = proxy.screen_reader_enabled().await
{
enabled = status;
}
}
_ = output.send(Response::Init(enabled, tx)).await;
Some(State {
conn,

View file

@ -21,12 +21,12 @@ pub async fn handle_wireless_device(
let mut scan_changed = device.receive_last_scan_changed().await;
if let Some(t) = scan_changed.next().await {
if let Ok(-1) = t.get().await {
if let Some(t) = scan_changed.next().await
&& let Ok(-1) = t.get().await
{
tracing::error!("wireless device scan errored");
return Ok(Default::default());
}
}
let access_points = device.get_access_points().await?;
@ -45,18 +45,19 @@ pub async fn handle_wireless_device(
if let Some((ssid, strength)) = ssid_res.ok().zip(strength_res.ok()) {
let ssid = String::from_utf8_lossy(&ssid.clone()).into_owned();
if let Some(access_point) = aps.get(&ssid) {
if access_point.strength > strength {
if let Some(access_point) = aps.get(&ssid)
&& access_point.strength > strength
{
continue;
}
}
let Ok(flags) = ap.rsn_flags().await else {
continue;
};
let network_type = if flags.intersects(ApSecurityFlags::KEY_MGMT_802_1X) {
NetworkType::EAP
} else if flags.intersects(ApSecurityFlags::KEY_MGMTPSK | ApSecurityFlags::KEY_MGMT_SAE) {
} else if flags.intersects(ApSecurityFlags::KEY_MGMTPSK | ApSecurityFlags::KEY_MGMT_SAE)
{
NetworkType::PskOrSae
} else if flags.intersects(ApSecurityFlags::KEY_MGMT_OWE) || flags.is_empty() {
NetworkType::Open

View file

@ -18,8 +18,8 @@ impl HwAddress {
.ok()
.map(|address| HwAddress { address })
}
pub fn from_string(arg: &String) -> Option<Self> {
HwAddress::from_str(arg.as_str())
pub fn from_string(arg: &str) -> Option<Self> {
HwAddress::from_str(arg)
}
}

View file

@ -16,7 +16,6 @@ pub use cosmic_dbus_networkmanager as dbus;
pub use dbus::settings::connection::Settings;
use cosmic_dbus_networkmanager::{
active_connection::ActiveConnection,
device::SpecificDevice,
interface::{
enums::{self, ActiveConnectionState, DeviceType, NmConnectivityState},
@ -185,14 +184,13 @@ async fn start_listening(
let mut changed = c.receive_state_changed().await;
_ = tokio::time::timeout(Duration::from_secs(5), async move {
loop {
if let Some(next) = changed.next().await {
if let Ok(ActiveConnectionState::Deactivated) =
if let Some(next) = changed.next().await
&& let Ok(ActiveConnectionState::Deactivated) =
next.get().await.map(ActiveConnectionState::from)
{
break;
}
}
}
})
.await;
}
@ -222,14 +220,13 @@ async fn start_listening(
let mut changed = c.receive_state_changed().await;
_ = tokio::time::timeout(Duration::from_secs(5), async move {
loop {
if let Some(next) = changed.next().await {
if let Ok(ActiveConnectionState::Deactivated) =
if let Some(next) = changed.next().await
&& let Ok(ActiveConnectionState::Deactivated) =
next.get().await.map(ActiveConnectionState::from)
{
break;
}
}
}
})
.await;
}
@ -528,7 +525,8 @@ async fn start_listening(
})
.await;
}
});
})
.await;
} else {
let known_conns = s.list_connections().await.unwrap_or_default();
for c in known_conns {
@ -540,10 +538,10 @@ async fn start_listening(
.clone()
.and_then(|w| w.ssid)
.and_then(|s| String::from_utf8(s).ok())
&& saved_ssid == ssid.as_ref()
{
if saved_ssid == ssid.as_ref() {
let password =
c.get_secrets("802-11-wireless-security")
let password = c
.get_secrets("802-11-wireless-security")
.await
.ok()
.and_then(|secrets| {
@ -581,7 +579,6 @@ async fn start_listening(
}
}
}
}
None => {
return State::Finished;
@ -616,13 +613,12 @@ async fn has_saved_wifi_credentials(conn: &zbus::Connection, ssid: &str) -> bool
.wifi
.and_then(|w| w.ssid)
.and_then(|ssid| String::from_utf8(ssid).ok())
&& saved_ssid == ssid
{
if saved_ssid == ssid {
return true;
}
}
}
}
false
}
@ -983,13 +979,12 @@ impl NetworkManagerState {
.clone()
.and_then(|w| w.ssid)
.and_then(|ssid| String::from_utf8(ssid).ok())
&& cur_ssid == ssid
{
if cur_ssid == ssid {
known_conn = Some(c);
break;
}
}
}
let known_conn = if let Some(known_conn) = known_conn {
if (secret_tx.is_none() && password.is_some()) || identity.is_some() {
@ -1014,9 +1009,9 @@ impl NetworkManagerState {
.ok_or_else(|| Error::MissingField("uuid"))?
.clone(),
)
.map_err(|err| zbus::Error::Variant(err))?;
.map_err(zbus::Error::Variant)?;
if let Some((pass, secret_tx)) = password.clone().zip(secret_tx.as_ref()) {
if let Some((pass, secret_tx)) = password.zip(secret_tx.as_ref()) {
let pass = SecureString::from(pass);
let (applied_tx, applied_rx) = tokio::sync::oneshot::channel();
@ -1056,7 +1051,7 @@ impl NetworkManagerState {
.ok_or_else(|| Error::MissingField("uuid"))?
.clone(),
)
.map_err(|err| zbus::Error::Variant(err))?;
.map_err(zbus::Error::Variant)?;
let (applied_tx, applied_rx) = tokio::sync::oneshot::channel();
let setting_name: String = if identity.is_some() {
"802-1x".into()
@ -1081,8 +1076,7 @@ impl NetworkManagerState {
}
}
let active_conn =
ActiveConnection::from(nm.activate_connection(&known_conn, &device).await?);
let active_conn = nm.activate_connection(&known_conn, &device).await?;
let mut changes = active_conn.receive_state_changed().await;
_ = tokio::time::sleep(tokio::time::Duration::from_millis(500)).await;
let mut count = 5;
@ -1120,7 +1114,7 @@ impl NetworkManagerState {
.ok_or_else(|| Error::MissingField("uuid"))?
.clone(),
)
.map_err(|err| zbus::Error::Variant(err))?;
.map_err(zbus::Error::Variant)?;
let (applied_tx, applied_rx) = tokio::sync::oneshot::channel();
let setting_name: String = if identity.is_some() {
"802-1x".into()

View file

@ -16,7 +16,7 @@ use zbus::{
pub type SecretSender = Arc<tokio::sync::Mutex<Option<tokio::sync::oneshot::Sender<SecureString>>>>;
pub const SECRET_ID: &'static str = "com.system76.CosmicSettings.NetworkManager";
pub const SECRET_ID: &str = "com.system76.CosmicSettings.NetworkManager";
pub const DBUS_PATH: &str = "/org/freedesktop/NetworkManager/SecretAgent";
bitflags! {
@ -151,10 +151,10 @@ async fn secret_agent_stream_impl(
{
let ss = secret_service::SecretService::connect(secret_service::EncryptionType::Dh)
.await
.map_err(|e| Arc::new(e))?;
let collection = ss.get_default_collection().await.map_err(|e| Arc::new(e))?;
if collection.is_locked().await.map_err(|e| Arc::new(e))? {
_ = collection.unlock().await.map_err(|e| Arc::new(e))?;
.map_err(Arc::new)?;
let collection = ss.get_default_collection().await.map_err(Arc::new)?;
if collection.is_locked().await.map_err(Arc::new)? {
collection.unlock().await.map_err(Arc::new)?;
}
}
// register the secret agent with NetworkManager
@ -183,8 +183,8 @@ async fn secret_agent_stream_impl(
} => {
let ss = secret_service::SecretService::connect(secret_service::EncryptionType::Dh)
.await
.map_err(|e| Arc::new(e))?;
let collection = ss.get_default_collection().await.map_err(|e| Arc::new(e))?;
.map_err(Arc::new)?;
let collection = ss.get_default_collection().await.map_err(Arc::new)?;
if secrets.is_empty() {
let mut attributes = std::collections::HashMap::new();
@ -193,10 +193,10 @@ async fn secret_agent_stream_impl(
let search_items = collection
.search_items(attributes)
.await
.map_err(|e| Arc::new(e))?;
.map_err(Arc::new)?;
for item in &search_items {
item.delete().await.map_err(|e| Arc::new(e))?;
item.delete().await.map_err(Arc::new)?;
}
let _ = applied_tx.send(());
@ -218,7 +218,7 @@ async fn secret_agent_stream_impl(
"text/plain",
)
.await
.map_err(|e| Arc::new(e))?;
.map_err(Arc::new)?;
}
let _ = applied_tx.send(());
}
@ -229,8 +229,8 @@ async fn secret_agent_stream_impl(
} => {
let ss = secret_service::SecretService::connect(secret_service::EncryptionType::Dh)
.await
.map_err(|e| Arc::new(e))?;
let collection = ss.get_default_collection().await.map_err(|e| Arc::new(e))?;
.map_err(Arc::new)?;
let collection = ss.get_default_collection().await.map_err(Arc::new)?;
let mut attributes = std::collections::HashMap::new();
attributes.insert("application", SECRET_ID);
@ -240,19 +240,19 @@ async fn secret_agent_stream_impl(
let search_items = collection
.search_items(attributes)
.await
.map_err(|e| Arc::new(e))?;
.map_err(Arc::new)?;
let mut secrets = HashMap::new();
for item in &search_items {
let name = item
.get_attributes()
.await
.map_err(|e| Arc::new(e))?
.map_err(Arc::new)?
.get("name")
.cloned()
.unwrap_or_else(|| "unknown".to_string());
let secret = item.get_secret().await.map_err(|e| Arc::new(e))?;
let secret: String = String::from_utf8(secret)?.into();
let secret = item.get_secret().await.map_err(Arc::new)?;
let secret: String = String::from_utf8(secret)?;
secrets.insert(name, SecureString::from(secret));
}
let _ = resp_tx.send(secrets);
@ -382,7 +382,7 @@ impl SettingsSecretAgent {
let conn = ConnectionSettingsProxy::builder(
&zbus::Connection::system()
.await
.or_else(|_| Err(fdo::Error::Failed("failed to get uuid".to_string())))?,
.map_err(|_| fdo::Error::Failed("failed to get uuid".to_string()))?,
)
.path(connection_path)?
.build()
@ -437,13 +437,9 @@ impl SettingsSecretAgent {
hints: Vec<String>,
flags: u32,
) -> HashMap<String, HashMap<String, zbus::zvariant::OwnedValue>> {
match self
.get_secrets_inner(connection, connection_path, setting_name, hints, flags)
self.get_secrets_inner(connection, connection_path, setting_name, hints, flags)
.await
{
Ok(result) => result,
Err(_) => HashMap::new(),
}
.unwrap_or_default()
}
/// SaveSecrets method
@ -472,9 +468,9 @@ impl SettingsSecretAgent {
let ss = secret_service::SecretService::connect(secret_service::EncryptionType::Dh)
.await
.map_err(|e| Arc::new(e))?;
.map_err(Arc::new)?;
let collection = ss.get_default_collection().await.map_err(|e| Arc::new(e))?;
let collection = ss.get_default_collection().await.map_err(Arc::new)?;
let conn_uuid = connection
.get("connection")
@ -484,10 +480,8 @@ impl SettingsSecretAgent {
.to_string();
let conn =
ConnectionSettingsProxy::builder(&zbus::Connection::system().await.or_else(|_| {
Err(Error::Zbus(
fdo::Error::Failed("failed to get uuid".to_string()).into(),
))
ConnectionSettingsProxy::builder(&zbus::Connection::system().await.map_err(|_| {
Error::Zbus(fdo::Error::Failed("failed to get uuid".to_string()).into())
})?)
.path(connection_path)?
.build()
@ -498,7 +492,7 @@ impl SettingsSecretAgent {
.get("connection")
.and_then(|m| m.get("type"))
.and_then(|v| v.downcast_ref::<String>().ok())
.map_or(false, |t| t == "vpn");
.is_some_and(|t| t == "vpn");
let is_always_ask = is_connection_always_ask(&settings);
let mut setting_attributes = std::collections::HashMap::new();
@ -509,7 +503,7 @@ impl SettingsSecretAgent {
let search_items = collection
.search_items(setting_attributes.clone())
.await
.map_err(|e| Arc::new(e))?;
.map_err(Arc::new)?;
let mut result = HashMap::new();
let mut setting = HashMap::new();
@ -518,16 +512,16 @@ impl SettingsSecretAgent {
let name = item
.get_attributes()
.await
.map_err(|e| Arc::new(e))?
.map_err(Arc::new)?
.get("name")
.cloned()
.unwrap_or_else(|| "unknown".to_string());
let secret = item.get_secret().await.map_err(|e| Arc::new(e))?;
let secret: String = String::from_utf8(secret)?.into();
let secret = item.get_secret().await.map_err(Arc::new)?;
let secret: String = String::from_utf8(secret)?;
setting.insert(name, zbus::zvariant::OwnedValue::from(Str::from(secret)));
}
result.insert(setting_name, setting);
return Ok(result);
Ok(result)
} else {
let hints = parse_hints(hints);
let mut requested = HashSet::new();
@ -563,8 +557,7 @@ impl SettingsSecretAgent {
&& e.is_disconnected()
{
continue;
} else {
if let Ok(secret) = resp_rx.await {
} else if let Ok(secret) = resp_rx.await {
let mut named_attribute = setting_attributes.clone();
named_attribute.insert("name", key);
let _item = collection
@ -576,21 +569,21 @@ impl SettingsSecretAgent {
"text/plain",
)
.await
.map_err(|e| Arc::new(e))?;
.map_err(Arc::new)?;
setting.insert(
key.clone(),
zbus::zvariant::OwnedValue::from(Str::from(secret.unsecure())),
);
}
}
} else if !is_always_ask {
let mut pos = None;
let mut pos_with_message = None;
for item in &search_items {
let attributes = item.get_attributes().await.map_err(|e| Arc::new(e))?;
if let Some(value) = attributes.get("name") {
if value == key {
let attributes = item.get_attributes().await.map_err(Arc::new)?;
if let Some(value) = attributes.get("name")
&& value == key
{
if let Some(saved_message) = attributes.get("message") {
if message.as_ref().is_some_and(|msg| msg == saved_message) {
pos_with_message = Some(item);
@ -601,11 +594,10 @@ impl SettingsSecretAgent {
}
}
}
}
if let Some(item) = pos_with_message.or(pos) {
let secret = item.get_secret().await.map_err(|e| Arc::new(e))?;
let secret: String = String::from_utf8(secret)?.into();
let secret = item.get_secret().await.map_err(Arc::new)?;
let secret: String = String::from_utf8(secret)?;
if is_vpn {
// ask anyway, but offer the previous one as a hint
let (resp_tx, resp_rx) = oneshot::channel();
@ -628,8 +620,7 @@ impl SettingsSecretAgent {
&& e.is_disconnected()
{
continue;
} else {
if let Ok(secret) = resp_rx.await {
} else if let Ok(secret) = resp_rx.await {
let mut named_attribute = setting_attributes.clone();
named_attribute.insert("name", key);
let _item = collection
@ -641,16 +632,13 @@ impl SettingsSecretAgent {
"text/plain",
)
.await
.map_err(|e| Arc::new(e))?;
.map_err(Arc::new)?;
setting.insert(
key.clone(),
zbus::zvariant::OwnedValue::from(Str::from(
secret.unsecure(),
)),
zbus::zvariant::OwnedValue::from(Str::from(secret.unsecure())),
);
}
}
} else {
setting.insert(
key.clone(),
@ -664,7 +652,7 @@ impl SettingsSecretAgent {
}
}
result.insert(setting_name, setting);
return Ok(result);
Ok(result)
}
}
@ -675,8 +663,8 @@ impl SettingsSecretAgent {
) -> Result<(), Error> {
let ss = secret_service::SecretService::connect(secret_service::EncryptionType::Dh)
.await
.map_err(|e| Arc::new(e))?;
let collection = ss.get_default_collection().await.map_err(|e| Arc::new(e))?;
.map_err(Arc::new)?;
let collection = ss.get_default_collection().await.map_err(Arc::new)?;
let conn_uuid = connection
.get("connection")
@ -692,10 +680,10 @@ impl SettingsSecretAgent {
let search_items = collection
.search_items(attributes)
.await
.map_err(|e| Arc::new(e))?;
.map_err(Arc::new)?;
for item in &search_items {
item.delete().await.map_err(|e| Arc::new(e))?;
item.delete().await.map_err(Arc::new)?;
}
Ok(())
}
@ -706,8 +694,8 @@ impl SettingsSecretAgent {
) -> Result<(), Error> {
let ss = secret_service::SecretService::connect(secret_service::EncryptionType::Dh)
.await
.map_err(|e| Arc::new(e))?;
let collection = ss.get_default_collection().await.map_err(|e| Arc::new(e))?;
.map_err(Arc::new)?;
let collection = ss.get_default_collection().await.map_err(Arc::new)?;
let conn_uuid = connection
.get("connection")
.and_then(|m| m.get("uuid"))
@ -741,7 +729,7 @@ impl SettingsSecretAgent {
"text/plain",
)
.await
.map_err(|e| Arc::new(e))?;
.map_err(Arc::new)?;
Ok(())
} else {
Err(Error::NoPasswordForIdentifier("unknown".to_string()))

View file

@ -251,7 +251,7 @@ impl Model {
None
} else {
self.node_names.get(node_id).map(|name| name.clone())
self.node_names.get(node_id).cloned()
};
tokio::task::spawn(async move {
@ -327,10 +327,8 @@ impl Model {
}
None
} else if let Some(name) = self.node_names.get(node_id) {
Some(name.clone())
} else {
None
self.node_names.get(node_id).cloned()
};
tokio::task::spawn(async move {
@ -527,11 +525,11 @@ impl Model {
}
pipewire::Event::AddProfile(id, index, profile) => {
if let Some(p) = self.active_profiles.get_mut(id) {
if p.index == profile.index {
if let Some(p) = self.active_profiles.get_mut(id)
&& p.index == profile.index
{
*p = profile.clone();
}
}
let profiles = self.device_profiles.entry(id).or_default();
if profiles.len() < index as usize + 1 {
@ -716,13 +714,13 @@ impl Model {
if let Some(pos) = self.sink_node_ids.iter().position(|&node_id| node_id == id) {
self.sink_node_ids.remove(pos);
self.sinks.remove(pos);
if let Some(node_id) = self.active_sink_node {
if id == node_id {
if let Some(node_id) = self.active_sink_node
&& id == node_id
{
self.active_sink = None;
self.active_sink_node = None;
self.active_sink_node_name.clear();
}
}
} else if let Some(pos) = self
.source_node_ids
.iter()
@ -730,14 +728,14 @@ impl Model {
{
self.source_node_ids.remove(pos);
self.sources.remove(pos);
if let Some(node_id) = self.active_source_node {
if id == node_id {
if let Some(node_id) = self.active_source_node
&& id == node_id
{
self.active_source = None;
self.active_source_node = None;
self.active_source_node_name.clear();
}
}
}
_ = self.device_ids.remove(id);
_ = self.node_names.remove(id);