Fix calendar visibility preservation during event updates
All checks were successful
Build and Push Docker Image / docker (push) Successful in 1m5s

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 <noreply@anthropic.com>
This commit is contained in:
Connor Johnstone
2025-09-24 11:20:43 -04:00
parent c938f25951
commit 933d7a8c1b

View File

@@ -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 &current_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::<String>("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));