From b32d9c6ee316ae796a96f8f2faa98e42dc73157f Mon Sep 17 00:00:00 2001 From: Gold856 <117957790+Gold856@users.noreply.github.com> Date: Mon, 11 Aug 2025 18:21:19 -0400 Subject: [PATCH] Only update UI when there's been a change in conflict detection (#2054) ## Description After #1991, the program state was always resent in an attempt to simplify logic, but this had the side effect of causing the settings UI to reset periodically when the hostname check was performed. This restores the original logic in #1791 to check for differences in the conflict state, and to only send the program state if it's changed. ## Meta Merge checklist: - [x] Pull Request title is [short, imperative summary](https://cbea.ms/git-commit/) of proposed changes - [x] The description documents the _what_ and _why_ - [ ] If this PR changes behavior or adds a feature, user documentation is updated - [ ] If this PR touches photon-serde, all messages have been regenerated and hashes have not changed unexpectedly - [ ] If this PR touches configuration, this is backwards compatible with settings back to v2024.3.1 - [ ] If this PR touches pipeline settings or anything related to data exchange, the frontend typing is updated - [ ] If this PR addresses a bug, a regression test for it is added --- .../networktables/NetworkTablesManager.java | 29 ++++++++++--------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/photon-core/src/main/java/org/photonvision/common/dataflow/networktables/NetworkTablesManager.java b/photon-core/src/main/java/org/photonvision/common/dataflow/networktables/NetworkTablesManager.java index 034ba5a7f..003b7d319 100644 --- a/photon-core/src/main/java/org/photonvision/common/dataflow/networktables/NetworkTablesManager.java +++ b/photon-core/src/main/java/org/photonvision/common/dataflow/networktables/NetworkTablesManager.java @@ -300,20 +300,21 @@ public class NetworkTablesManager { } } - // Publish the conflict status - DataChangeService.getInstance() - .publishEvent( - new OutgoingUIEvent<>( - "fullsettings", - UIPhotonConfiguration.programStateToUi(ConfigManager.getInstance().getConfig()))); - - conflictAlert.setText( - conflictingHostname - ? "Hostname conflict detected for " + hostname + "!" - : "" - + (conflictingCameras.isEmpty() - ? "" - : " Camera name conflict detected: " + conflictingCameras.toString() + "!")); + if (conflictingHostname != this.conflictingHostname + || !conflictingCameras.toString().equals(this.conflictingCameras)) { + // Only publish the conflict status when it's changed to prevent the settings cards from being + // forcibly reset + DataChangeService.getInstance() + .publishEvent( + new OutgoingUIEvent<>( + "fullsettings", + UIPhotonConfiguration.programStateToUi(ConfigManager.getInstance().getConfig()))); + } + if (conflictingHostname) { + conflictAlert.setText("Hostname conflict detected for " + hostname + "!"); + } else if (!conflictingCameras.isEmpty()) { + conflictAlert.setText("Camera name conflict detected: " + conflictingCameras + "!"); + } conflictAlert.set(conflictingHostname || !conflictingCameras.isEmpty()); SmartDashboard.updateValues(); this.conflictingHostname = conflictingHostname;