From 63968280b8fa35c6e1eb028983ca7ca2cdcda839 Mon Sep 17 00:00:00 2001 From: Connor Johnstone Date: Sun, 31 Aug 2025 00:45:56 -0400 Subject: [PATCH] Clean up unused code and compiler warnings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Removed unused functions and variables identified after RRULE parameter fix: - Remove unused build_series_rrule function from backend series handler - Remove unused RecurrenceType::from_rrule and helper functions from frontend - Prefix unused state variables with underscores to suppress warnings 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- backend/src/handlers/series.rs | 28 ------------- frontend/src/app.rs | 6 +-- frontend/src/components/create_event_modal.rs | 13 +----- frontend/src/services/calendar_service.rs | 41 ------------------- 4 files changed, 4 insertions(+), 84 deletions(-) diff --git a/backend/src/handlers/series.rs b/backend/src/handlers/series.rs index 75bebae..a69c595 100644 --- a/backend/src/handlers/series.rs +++ b/backend/src/handlers/series.rs @@ -460,34 +460,6 @@ pub async fn delete_event_series( // Helper functions -fn build_series_rrule(request: &CreateEventSeriesRequest) -> Result { - // Extract frequency from request - let recurrence_freq = if request.recurrence.contains("FREQ=") { - // Parse RRULE to extract frequency - if request.recurrence.contains("FREQ=DAILY") { - "daily" - } else if request.recurrence.contains("FREQ=WEEKLY") { - "weekly" - } else if request.recurrence.contains("FREQ=MONTHLY") { - "monthly" - } else if request.recurrence.contains("FREQ=YEARLY") { - "yearly" - } else { - return Err(ApiError::BadRequest("Invalid RRULE frequency".to_string())); - } - } else { - let lower = request.recurrence.to_lowercase(); - match lower.as_str() { - "daily" => "daily", - "weekly" => "weekly", - "monthly" => "monthly", - "yearly" => "yearly", - _ => return Err(ApiError::BadRequest("Invalid recurrence type".to_string())), - } - }; - - build_series_rrule_with_freq(request, recurrence_freq) -} fn build_series_rrule_with_freq(request: &CreateEventSeriesRequest, freq: &str) -> Result { let mut rrule_parts = Vec::new(); diff --git a/frontend/src/app.rs b/frontend/src/app.rs index d93e893..5cd3a86 100644 --- a/frontend/src/app.rs +++ b/frontend/src/app.rs @@ -54,9 +54,9 @@ pub fn App() -> Html { let calendar_context_menu_date = use_state(|| -> Option { None }); let create_event_modal_open = use_state(|| false); let selected_date_for_event = use_state(|| -> Option { None }); - let recurring_edit_modal_open = use_state(|| false); - let recurring_edit_event = use_state(|| -> Option { None }); - let recurring_edit_data = use_state(|| -> Option { None }); + let _recurring_edit_modal_open = use_state(|| false); + let _recurring_edit_event = use_state(|| -> Option { None }); + let _recurring_edit_data = use_state(|| -> Option { None }); // Calendar view state - load from localStorage if available let current_view = use_state(|| { diff --git a/frontend/src/components/create_event_modal.rs b/frontend/src/components/create_event_modal.rs index be1be23..3b04ac7 100644 --- a/frontend/src/components/create_event_modal.rs +++ b/frontend/src/components/create_event_modal.rs @@ -81,17 +81,6 @@ impl Default for RecurrenceType { } } -impl RecurrenceType { - pub fn from_rrule(rrule: Option<&str>) -> Self { - match rrule { - Some(rule) if rule.contains("FREQ=DAILY") => RecurrenceType::Daily, - Some(rule) if rule.contains("FREQ=WEEKLY") => RecurrenceType::Weekly, - Some(rule) if rule.contains("FREQ=MONTHLY") => RecurrenceType::Monthly, - Some(rule) if rule.contains("FREQ=YEARLY") => RecurrenceType::Yearly, - _ => RecurrenceType::None, - } - } -} /// Parse RRULE string into recurrence components /// Example RRULE: "FREQ=WEEKLY;INTERVAL=2;BYDAY=MO,WE,FR;UNTIL=20231215T000000Z" @@ -763,7 +752,7 @@ pub fn create_event_modal(props: &CreateEventModalProps) -> Html { }) }; - let on_priority_input = { + let _on_priority_input = { let event_data = event_data.clone(); Callback::from(move |e: InputEvent| { if let Some(input) = e.target_dyn_into::() { diff --git a/frontend/src/services/calendar_service.rs b/frontend/src/services/calendar_service.rs index 9cd4e4e..ca242d8 100644 --- a/frontend/src/services/calendar_service.rs +++ b/frontend/src/services/calendar_service.rs @@ -866,34 +866,6 @@ impl CalendarService { } - /// Calculate next weekday occurrence for WEEKLY frequency with BYDAY - fn next_weekday_occurrence(current_date: NaiveDate, byday: &str, interval: i32) -> NaiveDate { - let weekdays = Self::parse_byday(byday); - if weekdays.is_empty() { - return current_date + Duration::weeks(interval as i64); - } - - let current_weekday = current_date.weekday(); - - // Find next occurrence within current week - let mut next_occurrences = Vec::new(); - for &target_weekday in &weekdays { - let days_until = Self::days_until_weekday(current_weekday, target_weekday); - if days_until > 0 { - next_occurrences.push((days_until, target_weekday)); - } - } - - // Sort by days_until and return the closest one - if !next_occurrences.is_empty() { - next_occurrences.sort_by_key(|(days, _)| *days); - return current_date + Duration::days(next_occurrences[0].0 as i64); - } - - // No more occurrences this week, move to next interval - let next_week_start = current_date + Duration::weeks(interval as i64) - Duration::days(current_weekday.num_days_from_monday() as i64); - next_week_start + Duration::days(weekdays[0].num_days_from_monday() as i64) - } /// Parse BYDAY parameter (e.g., "MO,WE,FR" -> [Monday, Wednesday, Friday]) fn parse_byday(byday: &str) -> Vec { @@ -912,19 +884,6 @@ impl CalendarService { .collect() } - /// Calculate days until target weekday - fn days_until_weekday(from: Weekday, to: Weekday) -> i32 { - let from_num = from.num_days_from_monday(); - let to_num = to.num_days_from_monday(); - - if to_num > from_num { - (to_num - from_num) as i32 - } else if to_num < from_num { - (7 + to_num - from_num) as i32 - } else { - 0 // Same day - } - } /// Add months to a date (handling month boundary issues) fn add_months(date: NaiveDate, months: i32) -> Option {