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) => {
|
BluerRequest::ConnectDevice(add) => {
|
||||||
self.bluer_state
|
if let Some(d) = self
|
||||||
|
.bluer_state
|
||||||
.devices
|
.devices
|
||||||
.iter_mut()
|
.iter_mut()
|
||||||
.find(|d| d.address == *add)
|
.find(|d| d.address == *add)
|
||||||
.map(|d| {
|
{
|
||||||
d.status = BluerDeviceStatus::Connecting;
|
d.status = BluerDeviceStatus::Connecting;
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
BluerRequest::DisconnectDevice(add) => {
|
BluerRequest::DisconnectDevice(add) => {
|
||||||
self.bluer_state
|
if let Some(d) = self
|
||||||
|
.bluer_state
|
||||||
.devices
|
.devices
|
||||||
.iter_mut()
|
.iter_mut()
|
||||||
.find(|d| d.address == *add)
|
.find(|d| d.address == *add)
|
||||||
.map(|d| {
|
{
|
||||||
d.status = BluerDeviceStatus::Disconnecting;
|
d.status = BluerDeviceStatus::Disconnecting;
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
BluerRequest::PairDevice(add) => {
|
BluerRequest::PairDevice(add) => {
|
||||||
self.bluer_state
|
if let Some(d) = self
|
||||||
|
.bluer_state
|
||||||
.devices
|
.devices
|
||||||
.iter_mut()
|
.iter_mut()
|
||||||
.find(|d| d.address == *add)
|
.find(|d| d.address == *add)
|
||||||
.map(|d| {
|
{
|
||||||
d.status = BluerDeviceStatus::Pairing;
|
d.status = BluerDeviceStatus::Pairing;
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
_ => {} // TODO
|
_ => {} // TODO
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -358,13 +358,14 @@ impl cosmic::Application for CosmicNetworkApplet {
|
||||||
}
|
}
|
||||||
Message::ActivateKnownWifi(ssid) => {
|
Message::ActivateKnownWifi(ssid) => {
|
||||||
let tx = if let Some(tx) = self.nm_sender.as_ref() {
|
let tx = if let Some(tx) = self.nm_sender.as_ref() {
|
||||||
self.nm_state
|
if let Some(ap) = self
|
||||||
|
.nm_state
|
||||||
.known_access_points
|
.known_access_points
|
||||||
.iter_mut()
|
.iter_mut()
|
||||||
.find(|c| c.ssid == ssid)
|
.find(|c| c.ssid == ssid)
|
||||||
.map(|ap| {
|
{
|
||||||
ap.working = true;
|
ap.working = true;
|
||||||
});
|
}
|
||||||
tx
|
tx
|
||||||
} else {
|
} else {
|
||||||
return Command::none();
|
return Command::none();
|
||||||
|
|
@ -376,16 +377,19 @@ impl cosmic::Application for CosmicNetworkApplet {
|
||||||
}
|
}
|
||||||
Message::Disconnect(ssid) => {
|
Message::Disconnect(ssid) => {
|
||||||
let tx = if let Some(tx) = self.nm_sender.as_ref() {
|
let tx = if let Some(tx) = self.nm_sender.as_ref() {
|
||||||
self.nm_state
|
if let Some(ap) = self
|
||||||
|
.nm_state
|
||||||
.active_conns
|
.active_conns
|
||||||
.iter_mut()
|
.iter_mut()
|
||||||
.find(|c| c.name() == ssid)
|
.find(|c| c.name() == ssid)
|
||||||
.map(|ap| match ap {
|
{
|
||||||
|
match ap {
|
||||||
ActiveConnectionInfo::WiFi { state, .. } => {
|
ActiveConnectionInfo::WiFi { state, .. } => {
|
||||||
*state = ActiveConnectionState::Deactivating;
|
*state = ActiveConnectionState::Deactivating;
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
});
|
}
|
||||||
|
}
|
||||||
tx
|
tx
|
||||||
} else {
|
} else {
|
||||||
return Command::none();
|
return Command::none();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue