Clean up debug logs and add comprehensive documentation for this_and_future logic

This commit improves code maintainability by:

1. **Removing excessive debug logging**:
   - Cleaned up verbose datetime parsing and CalDAV operation logs
   - Kept essential error logging and status messages
   - Simplified request flow logging for better readability

2. **Adding comprehensive documentation**:
   - Detailed RFC 5545 compliant series splitting explanation
   - Clear operation overview with real-world examples
   - Frontend/backend interaction documentation
   - CalDAV operation sequencing and race condition prevention
   - Error handling and parameter validation details

The documentation explains how "this and future events" works:
- **Backend**: Creates comprehensive function-level docs with examples
- **Frontend**: Explains the user interaction flow and technical implementation
- **Integration**: Documents the atomic request handling and parameter passing

This makes the codebase more maintainable and helps future developers
understand the complex recurring event modification logic.

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

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Connor Johnstone
2025-08-30 20:23:48 -04:00
parent 783e13eb10
commit 9536158f58
3 changed files with 106 additions and 123 deletions

View File

@@ -160,8 +160,28 @@ pub fn week_view(props: &WeekViewProps) -> Html {
}
},
RecurringEditAction::FutureEvents => {
// Split series and modify future events
// 1. Update original series to set UNTIL to end before this occurrence
// RFC 5545 Compliant Series Splitting: "This and Future Events"
//
// When a user chooses to modify "this and future events" for a recurring series,
// we implement a series split operation that:
//
// 1. **Terminates Original Series**: The existing series is updated with an UNTIL
// clause to stop before the occurrence being modified
// 2. **Creates New Series**: A new recurring series is created starting from the
// occurrence date with the user's modifications (new time, title, etc.)
//
// Example: User drags Aug 22 occurrence of "Daily 9AM meeting" to 2PM:
// - Original: "Daily 9AM meeting" → ends Aug 21 (UNTIL=Aug22T000000Z)
// - New: "Daily 2PM meeting" → starts Aug 22, continues indefinitely
//
// This approach ensures:
// - Past occurrences remain unchanged (preserves user's historical data)
// - Future occurrences reflect the new modifications
// - CalDAV compatibility through proper RRULE manipulation
// - No conflicts with existing calendar applications
//
// The backend handles both operations atomically within a single API call
// to prevent race conditions and ensure data consistency.
if let Some(update_callback) = &on_event_update {
// Find the original series event (not the occurrence)
// UIDs like "uuid-timestamp" need to split on the last hyphen, not the first
@@ -216,17 +236,30 @@ pub fn week_view(props: &WeekViewProps) -> Html {
until_utc.format("%Y-%m-%d %H:%M:%S UTC"),
edit.event.dtstart.format("%Y-%m-%d %H:%M:%S UTC")).into());
// Use the dragged times for the new series (not the original series times)
let new_start = edit.new_start; // The dragged start time
// Critical: Use the dragged times (new_start/new_end) not the original series times
// This ensures the new series reflects the user's drag operation
let new_start = edit.new_start; // The dragged start time
let new_end = edit.new_end; // The dragged end time
// Send until_date to backend instead of modifying RRULE on frontend
// Extract occurrence date from the dragged event for backend processing
// Format: YYYY-MM-DD (e.g., "2025-08-22")
// This tells the backend which specific occurrence is being modified
let occurrence_date = edit.event.dtstart.format("%Y-%m-%d").to_string();
update_callback.emit((original_series, new_start, new_end, true, Some(until_utc), Some("this_and_future".to_string()), Some(occurrence_date))); // preserve_rrule = true, backend will add UNTIL
// Send single request to backend with "this_and_future" scope
// Backend will atomically:
// 1. Add UNTIL clause to original series (stops before occurrence_date)
// 2. Create new series starting from occurrence_date with dragged times
update_callback.emit((
original_series, // Original event to terminate
new_start, // Dragged start time for new series
new_end, // Dragged end time for new series
true, // preserve_rrule = true
Some(until_utc), // UNTIL date for original series
Some("this_and_future".to_string()), // Update scope
Some(occurrence_date) // Date of occurrence being modified
));
}
// The backend will handle creating the new series as part of the this_and_future update
web_sys::console::log_1(&format!("✅ this_and_future update request sent - backend will handle both UPDATE (add UNTIL) and CREATE (new series) operations").into());
},
RecurringEditAction::AllEvents => {
// Modify the entire series