Fix clippy nags
This commit is contained in:
@ -144,7 +144,7 @@ fn wind_speed_to_beaufort(mps: f64) -> BeaufortScale {
|
||||
let index = beaufort_wind_speeds
|
||||
.iter()
|
||||
.enumerate()
|
||||
.find_map(|(i, range)| range.contains(&mps).then(|| i))
|
||||
.find_map(|(i, range)| range.contains(&mps).then_some(i))
|
||||
.unwrap_or(beaufort_wind_speeds.len());
|
||||
|
||||
BeaufortScale(index as u8)
|
||||
|
||||
@ -112,20 +112,19 @@ pub async fn lights_task(state: &State) {
|
||||
};
|
||||
|
||||
if let Some(time) = time {
|
||||
let handle = spawn(wake_task(
|
||||
state.client_message.clone(),
|
||||
cmd.clone(),
|
||||
id.clone(),
|
||||
day,
|
||||
time,
|
||||
));
|
||||
let handle = spawn(wake_task(
|
||||
state.client_message.clone(),
|
||||
cmd.clone(),
|
||||
id.clone(),
|
||||
day,
|
||||
time,
|
||||
));
|
||||
|
||||
if let Some(old_handle) = wake_tasks.insert((id, day), handle) {
|
||||
old_handle.abort();
|
||||
}} else {
|
||||
if let Some(old_handle) = wake_tasks.remove(&(id, day)) {
|
||||
if let Some(old_handle) = wake_tasks.insert((id, day), handle) {
|
||||
old_handle.abort();
|
||||
}
|
||||
} else if let Some(old_handle) = wake_tasks.remove(&(id, day)) {
|
||||
old_handle.abort();
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
@ -181,7 +180,11 @@ fn next_alarm(now: DateTime<Local>, day: Weekday, time: NaiveTime) -> DateTime<L
|
||||
let day_now = now.weekday().num_days_from_monday() as i64;
|
||||
|
||||
let alarm = now + chrono::Duration::days(day_of_alarm - day_now);
|
||||
let mut alarm = alarm.date().and_time(time).unwrap();
|
||||
let mut alarm = alarm
|
||||
.date_naive()
|
||||
.and_time(time)
|
||||
.and_local_timezone(Local)
|
||||
.unwrap();
|
||||
|
||||
if alarm <= now {
|
||||
alarm += chrono::Duration::weeks(1);
|
||||
|
||||
@ -19,7 +19,7 @@ pub struct ColorPicker {
|
||||
#[derive(Default)]
|
||||
enum ColorPickerSetting {
|
||||
#[default]
|
||||
HSB,
|
||||
Hsb,
|
||||
Kelvin,
|
||||
}
|
||||
|
||||
@ -55,14 +55,14 @@ impl ColorPicker {
|
||||
}
|
||||
|
||||
match self.dragging.take() {
|
||||
Some(ColorPickerAttr::HueSat) => self.mode = ColorPickerSetting::HSB,
|
||||
Some(ColorPickerAttr::HueSat) => self.mode = ColorPickerSetting::Hsb,
|
||||
Some(ColorPickerAttr::Brightness) => {}
|
||||
Some(ColorPickerAttr::Temperature) => self.mode = ColorPickerSetting::Kelvin,
|
||||
None => return,
|
||||
}
|
||||
|
||||
let color = match self.mode {
|
||||
ColorPickerSetting::HSB => {
|
||||
ColorPickerSetting::Hsb => {
|
||||
BulbColor::hsb(self.hue, self.saturation, self.brightness)
|
||||
}
|
||||
ColorPickerSetting::Kelvin => {
|
||||
@ -130,10 +130,12 @@ impl ColorPicker {
|
||||
|
||||
let (r, g, b) = hsb_to_rgb(self.hue, 1.0, 1.0);
|
||||
let saturation_gradient = match self.mode {
|
||||
ColorPickerSetting::HSB => {
|
||||
ColorPickerSetting::Hsb => {
|
||||
format!("background: linear-gradient(0deg, #000, rgba({r},{g},{b},1));")
|
||||
}
|
||||
ColorPickerSetting::Kelvin => format!("background: linear-gradient(0deg, #000, #fff);"),
|
||||
ColorPickerSetting::Kelvin => {
|
||||
"background: linear-gradient(0deg, #000, #fff);".to_string()
|
||||
}
|
||||
};
|
||||
|
||||
div![
|
||||
@ -186,7 +188,7 @@ impl ColorPicker {
|
||||
self.hue = h;
|
||||
self.saturation = s;
|
||||
self.brightness = b;
|
||||
self.mode = ColorPickerSetting::HSB;
|
||||
self.mode = ColorPickerSetting::Hsb;
|
||||
}
|
||||
|
||||
pub fn set_kelvin(&mut self, t: f32, b: f32) {
|
||||
|
||||
@ -112,7 +112,7 @@ impl Page for Model {
|
||||
}
|
||||
Msg::ColorPicker(msg) => {
|
||||
self.color_picker
|
||||
.update(msg, &mut orders.proxy(|msg| Msg::ColorPicker(msg)));
|
||||
.update(msg, &mut orders.proxy(Msg::ColorPicker));
|
||||
}
|
||||
Msg::SetBulbPower(power) => {
|
||||
self.groups_interacted = true;
|
||||
@ -125,7 +125,7 @@ impl Page for Model {
|
||||
});
|
||||
}
|
||||
Msg::LightTime(time, day) => {
|
||||
if time == "" {
|
||||
if time.is_empty() {
|
||||
self.for_selected_bulbs(|id, _| {
|
||||
let message = ClientMessage::SetBulbWakeTime {
|
||||
id: id.clone(),
|
||||
@ -259,9 +259,7 @@ impl Page for Model {
|
||||
div![
|
||||
C![C.bulb_controls],
|
||||
IF!(selected_bulb.is_none() => C![C.bulb_controls_disable]),
|
||||
self.color_picker
|
||||
.view()
|
||||
.map_msg(|msg| Msg::ColorPicker(msg)),
|
||||
self.color_picker.view().map_msg(Msg::ColorPicker),
|
||||
button![
|
||||
if selected_bulb.map(|b| b.mode.power).unwrap_or(false) {
|
||||
C![C.bulb_power_button, C.bulb_power_button_on]
|
||||
|
||||
Reference in New Issue
Block a user