From 44344f40142b8f5a547596a270d2c43ae4361369 Mon Sep 17 00:00:00 2001 From: Joe Date: Sun, 1 Feb 2026 20:21:24 -0600 Subject: [PATCH] Refactor syncback logic for camera removal handling - Simplified the logic for removing the current camera by using a default value for sync_current_camera, improving code readability. - Enhanced the handling of camera references within the syncback loop, ensuring that the camera is only removed when explicitly set to do so. - Updated comments for clarity on the default behavior regarding camera removal in the syncback process. --- src/syncback/mod.rs | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/src/syncback/mod.rs b/src/syncback/mod.rs index d7d07938..ece7ad5c 100644 --- a/src/syncback/mod.rs +++ b/src/syncback/mod.rs @@ -174,21 +174,25 @@ pub fn syncback_loop_with_stats( } // Handle removing the current camera. - if let Some(syncback_rules) = &project.syncback_rules { - if !syncback_rules.sync_current_camera.unwrap_or_default() { - log::debug!("Removing CurrentCamera from new DOM"); - let mut camera_ref = None; - for child_ref in new_tree.root().children() { - let inst = new_tree.get_by_ref(*child_ref).unwrap(); - if inst.class == "Workspace" { - camera_ref = inst.properties.get(&ustr("CurrentCamera")); - break; - } + // syncCurrentCamera defaults to false, meaning we remove the camera by default + let sync_current_camera = project + .syncback_rules + .as_ref() + .and_then(|s| s.sync_current_camera) + .unwrap_or(false); + if !sync_current_camera { + log::debug!("Removing CurrentCamera from new DOM"); + let mut camera_ref = None; + for child_ref in new_tree.root().children() { + let inst = new_tree.get_by_ref(*child_ref).unwrap(); + if inst.class == "Workspace" { + camera_ref = inst.properties.get(&ustr("CurrentCamera")); + break; } - if let Some(Variant::Ref(camera_ref)) = camera_ref { - if new_tree.get_by_ref(*camera_ref).is_some() { - new_tree.destroy(*camera_ref); - } + } + if let Some(Variant::Ref(camera_ref)) = camera_ref { + if new_tree.get_by_ref(*camera_ref).is_some() { + new_tree.destroy(*camera_ref); } } }