Skip to content

Commit

Permalink
fix: event is no longer assumed to be the first component in the cale…
Browse files Browse the repository at this point in the history
…ndar
  • Loading branch information
justinrubek committed Jan 18, 2023
1 parent a9a87ed commit 7d17347
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions crates/caldav-utils/src/availability/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,18 @@ pub fn get_event_matrix(
// First, we need to get the properties from the inner icalendar::Event.
let comps = &event.ical.components;
// Assume there is only one component.
let comp = comps.first().unwrap();
let event = comp.as_event().unwrap();
println!("comps: {:#?}", comps);
let event_comp = comps.iter().find(|c| match c {
icalendar::CalendarComponent::Event(_) => true,
_ => false,
});
if event_comp.is_none() {
return Err(CaldavError::Anyhow(anyhow!(
"no event component found in event"
)));
}
let event = event_comp.unwrap().as_event().unwrap();
println!("event: {:#?}", event);

// Get the start and end times of the event.
let dtstart_str = event.property_value("DTSTART").unwrap();
Expand Down

0 comments on commit 7d17347

Please sign in to comment.