avoid using 'map' and then returning '()'
This commit is contained in:
parent
c360a6158e
commit
e6010b147a
2 changed files with 26 additions and 19 deletions
|
|
@ -219,31 +219,34 @@ impl cosmic::Application for CosmicBluetoothApplet {
|
|||
}
|
||||
}
|
||||
BluerRequest::ConnectDevice(add) => {
|
||||
self.bluer_state
|
||||
if let Some(d) = self
|
||||
.bluer_state
|
||||
.devices
|
||||
.iter_mut()
|
||||
.find(|d| d.address == *add)
|
||||
.map(|d| {
|
||||
d.status = BluerDeviceStatus::Connecting;
|
||||
});
|
||||
{
|
||||
d.status = BluerDeviceStatus::Connecting;
|
||||
}
|
||||
}
|
||||
BluerRequest::DisconnectDevice(add) => {
|
||||
self.bluer_state
|
||||
if let Some(d) = self
|
||||
.bluer_state
|
||||
.devices
|
||||
.iter_mut()
|
||||
.find(|d| d.address == *add)
|
||||
.map(|d| {
|
||||
d.status = BluerDeviceStatus::Disconnecting;
|
||||
});
|
||||
{
|
||||
d.status = BluerDeviceStatus::Disconnecting;
|
||||
}
|
||||
}
|
||||
BluerRequest::PairDevice(add) => {
|
||||
self.bluer_state
|
||||
if let Some(d) = self
|
||||
.bluer_state
|
||||
.devices
|
||||
.iter_mut()
|
||||
.find(|d| d.address == *add)
|
||||
.map(|d| {
|
||||
d.status = BluerDeviceStatus::Pairing;
|
||||
});
|
||||
{
|
||||
d.status = BluerDeviceStatus::Pairing;
|
||||
}
|
||||
}
|
||||
_ => {} // TODO
|
||||
}
|
||||
|
|
|
|||
|
|
@ -358,13 +358,14 @@ impl cosmic::Application for CosmicNetworkApplet {
|
|||
}
|
||||
Message::ActivateKnownWifi(ssid) => {
|
||||
let tx = if let Some(tx) = self.nm_sender.as_ref() {
|
||||
self.nm_state
|
||||
if let Some(ap) = self
|
||||
.nm_state
|
||||
.known_access_points
|
||||
.iter_mut()
|
||||
.find(|c| c.ssid == ssid)
|
||||
.map(|ap| {
|
||||
ap.working = true;
|
||||
});
|
||||
{
|
||||
ap.working = true;
|
||||
}
|
||||
tx
|
||||
} else {
|
||||
return Command::none();
|
||||
|
|
@ -376,16 +377,19 @@ impl cosmic::Application for CosmicNetworkApplet {
|
|||
}
|
||||
Message::Disconnect(ssid) => {
|
||||
let tx = if let Some(tx) = self.nm_sender.as_ref() {
|
||||
self.nm_state
|
||||
if let Some(ap) = self
|
||||
.nm_state
|
||||
.active_conns
|
||||
.iter_mut()
|
||||
.find(|c| c.name() == ssid)
|
||||
.map(|ap| match ap {
|
||||
{
|
||||
match ap {
|
||||
ActiveConnectionInfo::WiFi { state, .. } => {
|
||||
*state = ActiveConnectionState::Deactivating;
|
||||
}
|
||||
_ => {}
|
||||
});
|
||||
}
|
||||
}
|
||||
tx
|
||||
} else {
|
||||
return Command::none();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue