fix: synchronize dynamic GeoServer layer lifecycle
Generic Container CI/CD / test-build-publish (push) Successful in 59s
Frontend CI/CD / build-test-publish-and-deploy (push) Successful in 59s

Optional sources became dynamic while dependent labels and controller state remained static, allowing stale requests to restore removed layers. Register dependent layers through the same lifecycle and invalidate target request generations before release.
This commit is contained in:
2026-09-11 18:25:41 +08:00
parent 31acd33a2e
commit bf44cc0f25
5 changed files with 303 additions and 13 deletions
@@ -67,11 +67,8 @@ export function useWorkbenchMapController({
controller.getSnapshot
);
useEffect(() => {
const target = state.target;
if (target && availableSourceIds && !availableSourceIds.includes(target.sourceId)) {
controller.clearHighlight();
}
}, [availableSourceIds, controller, state.target]);
if (availableSourceIds) controller.syncAvailableSources(availableSourceIds);
}, [availableSourceIds, controller]);
useEffect(() => () => controller.destroy(), [controller]);
return { controller, state };
}
@@ -276,7 +276,10 @@ export function useWorkbenchMap({
REQUIRED_GEOSERVER_SOURCE_IDS
).forEach((layer) => map.addLayer(layer));
scadaInteractionLayers.forEach((layer) => map.addLayer(layer));
createValueLabelLayers().forEach((layer) => map.addLayer(layer));
filterWaterNetworkLayersBySourceIds(
createValueLabelLayers(),
REQUIRED_GEOSERVER_SOURCE_IDS
).forEach((layer) => map.addLayer(layer));
simulationAnnotationLayers
.filter((layer) => layer.type === "symbol")
.forEach((layer) => map.addLayer(layer));
@@ -461,6 +464,17 @@ function syncDataDependentGeoServerLayers(
availableSourceIdSet,
layerVisibility
);
addMissingDataDependentLayers(
map,
createValueLabelLayers(),
[
...simulationAnnotationLayers.filter((layer) => layer.type === "symbol"),
...waterNetworkHitLayers,
...scadaHitLayers
].map((layer) => layer.id),
availableSourceIdSet,
layerVisibility
);
addMissingDataDependentLayers(
map,
waterNetworkHitLayers,