Use map
This commit is contained in:
parent
9db7e52704
commit
163356f012
1 changed files with 6 additions and 10 deletions
16
src/main.rs
16
src/main.rs
|
|
@ -193,11 +193,10 @@ impl State {
|
||||||
|
|
||||||
fn recreate_notification(&mut self) {
|
fn recreate_notification(&mut self) {
|
||||||
if self.screen_off_idle_notification.as_ref().map(|x| x.time) != self.conf.screen_off_time {
|
if self.screen_off_idle_notification.as_ref().map(|x| x.time) != self.conf.screen_off_time {
|
||||||
self.screen_off_idle_notification = if let Some(time) = self.conf.screen_off_time {
|
self.screen_off_idle_notification = self
|
||||||
Some(IdleNotification::new(&self.inner, time))
|
.conf
|
||||||
} else {
|
.screen_off_time
|
||||||
None
|
.map(|time| IdleNotification::new(&self.inner, time));
|
||||||
};
|
|
||||||
self.update_screen_off_idle(false);
|
self.update_screen_off_idle(false);
|
||||||
}
|
}
|
||||||
let suspend_time = if self.on_battery {
|
let suspend_time = if self.on_battery {
|
||||||
|
|
@ -206,11 +205,8 @@ impl State {
|
||||||
self.conf.suspend_on_ac_time
|
self.conf.suspend_on_ac_time
|
||||||
};
|
};
|
||||||
if self.suspend_idle_notification.as_ref().map(|x| x.time) != suspend_time {
|
if self.suspend_idle_notification.as_ref().map(|x| x.time) != suspend_time {
|
||||||
self.suspend_idle_notification = if let Some(time) = suspend_time {
|
self.suspend_idle_notification =
|
||||||
Some(IdleNotification::new(&self.inner, time))
|
suspend_time.map(|time| IdleNotification::new(&self.inner, time));
|
||||||
} else {
|
|
||||||
None
|
|
||||||
};
|
|
||||||
self.update_suspend_idle(false);
|
self.update_suspend_idle(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue