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));