Add calendar selection dropdown and fix multi-calendar event display
- Add calendar selection dropdown to event creation modal - Update EventCreationData to include selected_calendar field - Pass available calendars from user info to modal component - Initialize dropdown with first available calendar as default - Fix backend to fetch events from ALL calendars, not just the first - Update refresh_event to search across all calendars - Events created in any calendar now properly display in UI 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
		| @@ -39,11 +39,24 @@ pub async fn get_calendar_events( | ||||
|         return Ok(Json(vec![])); // No calendars found | ||||
|     } | ||||
|      | ||||
|     // Fetch events from the first calendar | ||||
|     let calendar_path = &calendar_paths[0]; | ||||
|     let events = client.fetch_events(calendar_path) | ||||
|         .await | ||||
|         .map_err(|e| ApiError::Internal(format!("Failed to fetch events: {}", e)))?; | ||||
|     // Fetch events from all calendars | ||||
|     let mut all_events = Vec::new(); | ||||
|     for calendar_path in &calendar_paths { | ||||
|         match client.fetch_events(calendar_path).await { | ||||
|             Ok(mut events) => { | ||||
|                 // Set calendar_path for each event to identify which calendar it belongs to | ||||
|                 for event in &mut events { | ||||
|                     event.calendar_path = Some(calendar_path.clone()); | ||||
|                 } | ||||
|                 all_events.extend(events); | ||||
|             }, | ||||
|             Err(e) => { | ||||
|                 // Log the error but continue with other calendars | ||||
|                 eprintln!("Failed to fetch events from calendar {}: {}", calendar_path, e); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|     let events = all_events; | ||||
|      | ||||
|     // Filter events by month if specified | ||||
|     let filtered_events = if let (Some(year), Some(month)) = (params.year, params.month) { | ||||
| @@ -80,11 +93,23 @@ pub async fn refresh_event( | ||||
|         return Ok(Json(None)); // No calendars found | ||||
|     } | ||||
|      | ||||
|     // Fetch the specific event by UID from the first calendar | ||||
|     let calendar_path = &calendar_paths[0]; | ||||
|     let event = client.fetch_event_by_uid(calendar_path, &uid) | ||||
|         .await | ||||
|         .map_err(|e| ApiError::Internal(format!("Failed to fetch event: {}", e)))?; | ||||
|     // Search for the specific event by UID across all calendars | ||||
|     let mut found_event = None; | ||||
|     for calendar_path in &calendar_paths { | ||||
|         match client.fetch_event_by_uid(calendar_path, &uid).await { | ||||
|             Ok(Some(mut event)) => { | ||||
|                 event.calendar_path = Some(calendar_path.clone()); | ||||
|                 found_event = Some(event); | ||||
|                 break; | ||||
|             }, | ||||
|             Ok(None) => continue, // Event not found in this calendar | ||||
|             Err(e) => { | ||||
|                 eprintln!("Failed to fetch event from calendar {}: {}", calendar_path, e); | ||||
|                 continue; | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|     let event = found_event; | ||||
|      | ||||
|     Ok(Json(event)) | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Connor Johnstone
					Connor Johnstone