Don't save and load empty alarm configs
_ => {},
}
}
+ let entries = entries.iter().filter(|e| {
+ !e.context.is_empty() && !e.device.is_empty()
+ }).collect::<Vec<&AlarmConfig>>();
for (idx,entry) in entries.iter().enumerate() {
conf.set_to(Some("alarms"), format!("alarm{}", idx+1), entry.to_string());
}
let repeat = fields.next().ok_or("Missing repeat")?;
let context = fields.next().ok_or("Missing context")?;
let device = fields.next().ok_or("Missing device")?;
+ if device.is_empty() || context.is_empty() || time.is_empty() {
+ return Err("Invalid alarm.".into());
+ }
let mut time_fields = time.split(":");
let hour = time_fields.next().ok_or("Missing hour")?;
let minute = time_fields.next().ok_or("Missing minute")?;