Fix event width bug: timed events showing half-width when all-day events exist

Timed events were incorrectly displaying at half-width when all-day events
existed on the same day, even though all-day events display separately at
the top of the calendar and don't visually overlap with timed events.

Root cause: The overlap calculation logic was including all-day events when
determining width splits for timed events.

Solution:
- Modified calculate_event_layout() to exclude all-day events from filtering
- Updated events_overlap() to return false if either event is all-day
- All-day events now don't participate in timed event width calculations

Result: Timed events display at full width unless they actually overlap
with other timed events, while all-day events continue to display correctly
in their separate section.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Connor Johnstone
2025-09-03 16:27:32 -04:00
parent 13a752a69c
commit 5ea33b7d0a

View File

@@ -1193,6 +1193,11 @@ fn calculate_event_position(event: &VEvent, date: NaiveDate, time_increment: u32
// Check if two events overlap in time // Check if two events overlap in time
fn events_overlap(event1: &VEvent, event2: &VEvent) -> bool { fn events_overlap(event1: &VEvent, event2: &VEvent) -> bool {
// All-day events don't overlap with timed events for width calculation purposes
if event1.all_day || event2.all_day {
return false;
}
let start1 = event1.dtstart.with_timezone(&Local).naive_local(); let start1 = event1.dtstart.with_timezone(&Local).naive_local();
let end1 = if let Some(end) = event1.dtend { let end1 = if let Some(end) = event1.dtend {
end.with_timezone(&Local).naive_local() end.with_timezone(&Local).naive_local()
@@ -1214,10 +1219,15 @@ fn events_overlap(event1: &VEvent, event2: &VEvent) -> bool {
// Calculate layout columns for overlapping events // Calculate layout columns for overlapping events
fn calculate_event_layout(events: &[VEvent], date: NaiveDate, time_increment: u32) -> Vec<(usize, usize)> { fn calculate_event_layout(events: &[VEvent], date: NaiveDate, time_increment: u32) -> Vec<(usize, usize)> {
// Filter and sort events that should appear on this date // Filter and sort events that should appear on this date (excluding all-day events)
let mut day_events: Vec<_> = events.iter() let mut day_events: Vec<_> = events.iter()
.enumerate() .enumerate()
.filter_map(|(idx, event)| { .filter_map(|(idx, event)| {
// Skip all-day events as they don't participate in timed event overlap calculations
if event.all_day {
return None;
}
let (_, _, _) = calculate_event_position(event, date, time_increment); let (_, _, _) = calculate_event_position(event, date, time_increment);
let local_start = event.dtstart.with_timezone(&Local); let local_start = event.dtstart.with_timezone(&Local);
let event_date = local_start.date_naive(); let event_date = local_start.date_naive();