fix: synchronize dynamic GeoServer layer lifecycle
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:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user