From 933d7a8c1b87be1857afdd58a2c245cf758eb3a5 Mon Sep 17 00:00:00 2001 From: Connor Johnstone Date: Wed, 24 Sep 2025 11:20:43 -0400 Subject: [PATCH] Fix calendar visibility preservation during event updates MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Prevent hidden calendars from becoming visible when events are modified via drag-and-drop or other update operations. The refresh mechanism was overwriting frontend visibility state with fresh server data that doesn't include visibility settings. Changes: - Preserve existing calendar visibility and color settings during refresh_calendar_data - Maintain smart fallback for saved colors on new calendars - Ensure calendar visibility state persists across event modifications This fixes the issue where users would hide calendars, then see them reappear after dragging events. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- frontend/src/app.rs | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/frontend/src/app.rs b/frontend/src/app.rs index 12f57ed..9e3de2c 100644 --- a/frontend/src/app.rs +++ b/frontend/src/app.rs @@ -295,7 +295,21 @@ pub fn App() -> Html { if !password.is_empty() { match calendar_service.fetch_user_info(&token, &password).await { Ok(mut info) => { - // Apply saved colors + // Preserve existing calendar settings (colors and visibility) from current state + if let Some(current_info) = (*user_info).clone() { + for current_cal in ¤t_info.calendars { + for cal in &mut info.calendars { + if cal.path == current_cal.path { + // Preserve visibility setting + cal.is_visible = current_cal.is_visible; + // Preserve color setting + cal.color = current_cal.color.clone(); + } + } + } + } + + // Apply saved colors as fallback for new calendars if let Ok(saved_colors_json) = LocalStorage::get::("calendar_colors") { @@ -304,13 +318,15 @@ pub fn App() -> Html { { for saved_cal in &saved_info.calendars { for cal in &mut info.calendars { - if cal.path == saved_cal.path { + if cal.path == saved_cal.path && cal.color == "#3B82F6" { + // Only apply saved color if it's still the default cal.color = saved_cal.color.clone(); } } } } } + // Add timestamp to force re-render info.last_updated = (js_sys::Date::now() / 1000.0) as u64; user_info.set(Some(info));