improve(bluetooth): ignore devices with unknown type and without alias
This commit is contained in:
parent
91dadaec90
commit
6fea8dc624
2 changed files with 11 additions and 1 deletions
|
|
@ -158,6 +158,8 @@ impl PartialEq for Adapter {
|
||||||
|
|
||||||
impl Eq for Adapter {}
|
impl Eq for Adapter {}
|
||||||
|
|
||||||
|
const default_device_icon: &str = "bluetooth-symbolic";
|
||||||
|
|
||||||
fn device_type_to_icon(device_type: &str) -> &'static str {
|
fn device_type_to_icon(device_type: &str) -> &'static str {
|
||||||
match device_type {
|
match device_type {
|
||||||
"computer" => "laptop-symbolic",
|
"computer" => "laptop-symbolic",
|
||||||
|
|
@ -173,7 +175,7 @@ fn device_type_to_icon(device_type: &str) -> &'static str {
|
||||||
"input-mouse" => "input-mouse-symbolic",
|
"input-mouse" => "input-mouse-symbolic",
|
||||||
"printer" => "printer-network-symbolic",
|
"printer" => "printer-network-symbolic",
|
||||||
"camera-photo" => "camera-photo-symbolic",
|
"camera-photo" => "camera-photo-symbolic",
|
||||||
_ => "bluetooth-symbolic",
|
_ => default_device_icon,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -266,6 +268,10 @@ impl Device {
|
||||||
self.alias.is_some()
|
self.alias.is_some()
|
||||||
}
|
}
|
||||||
#[must_use]
|
#[must_use]
|
||||||
|
pub fn is_known_device_type(&self) -> bool {
|
||||||
|
self.icon != default_device_icon
|
||||||
|
}
|
||||||
|
#[must_use]
|
||||||
pub fn alias_or_addr(&self) -> &str {
|
pub fn alias_or_addr(&self) -> &str {
|
||||||
self.alias.as_ref().unwrap_or(&self.address)
|
self.alias.as_ref().unwrap_or(&self.address)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -746,6 +746,10 @@ fn available_devices() -> Section<crate::pages::Message> {
|
||||||
return None::<Element<'_, Message>>;
|
return None::<Element<'_, Message>>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !device.is_known_device_type() && !device.has_alias() {
|
||||||
|
return None::<Element<'_, Message>>;
|
||||||
|
}
|
||||||
|
|
||||||
let mut items = vec![
|
let mut items = vec![
|
||||||
widget::icon::from_name(device.icon).size(16).into(),
|
widget::icon::from_name(device.icon).size(16).into(),
|
||||||
text(device.alias_or_addr()).wrapping(Wrapping::Word).into(),
|
text(device.alias_or_addr()).wrapping(Wrapping::Word).into(),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue