Skip to content

Commit b32d9c6

Browse files
authored
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
1 parent 7766d99 commit b32d9c6

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

photon-core/src/main/java/org/photonvision/common/dataflow/networktables/NetworkTablesManager.java

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -300,20 +300,21 @@ private void checkHostnameAndCameraNames() {
300300
}
301301
}
302302

303-
// Publish the conflict status
304-
DataChangeService.getInstance()
305-
.publishEvent(
306-
new OutgoingUIEvent<>(
307-
"fullsettings",
308-
UIPhotonConfiguration.programStateToUi(ConfigManager.getInstance().getConfig())));
309-
310-
conflictAlert.setText(
311-
conflictingHostname
312-
? "Hostname conflict detected for " + hostname + "!"
313-
: ""
314-
+ (conflictingCameras.isEmpty()
315-
? ""
316-
: " Camera name conflict detected: " + conflictingCameras.toString() + "!"));
303+
if (conflictingHostname != this.conflictingHostname
304+
|| !conflictingCameras.toString().equals(this.conflictingCameras)) {
305+
// Only publish the conflict status when it's changed to prevent the settings cards from being
306+
// forcibly reset
307+
DataChangeService.getInstance()
308+
.publishEvent(
309+
new OutgoingUIEvent<>(
310+
"fullsettings",
311+
UIPhotonConfiguration.programStateToUi(ConfigManager.getInstance().getConfig())));
312+
}
313+
if (conflictingHostname) {
314+
conflictAlert.setText("Hostname conflict detected for " + hostname + "!");
315+
} else if (!conflictingCameras.isEmpty()) {
316+
conflictAlert.setText("Camera name conflict detected: " + conflictingCameras + "!");
317+
}
317318
conflictAlert.set(conflictingHostname || !conflictingCameras.isEmpty());
318319
SmartDashboard.updateValues();
319320
this.conflictingHostname = conflictingHostname;

0 commit comments

Comments
 (0)