Skip to content

Commit 003dca0

Browse files
committed
Integrated peer comments
Can delete a layer that's not existing (only existing through the config)
1 parent aec981d commit 003dca0

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

packages/geoview-core/src/api/event-processors/abstract-event-processor.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -203,9 +203,9 @@ export abstract class AbstractEventProcessor {
203203
/**
204204
* Helper function to delete a layer information from an array when found.
205205
*
206-
* @param {T[]} layerArray - The layer array to work with
207-
* @param {string} layerPath - The layer path to delete
208-
* @param {(layerArray: T[]) => void} onDeleteCallback - The callback executed when the array is updated
206+
* @param layerArray - The layer array to work with
207+
* @param layerPath - The layer path to delete
208+
* @param onDeleteCallback - The callback executed when the array is updated
209209
*/
210210
protected static helperDeleteFromArray<T extends TypeResultSetEntry>(
211211
layerArray: T[],

packages/geoview-core/src/api/event-processors/event-processor-children/legend-event-processor.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1208,16 +1208,18 @@ export class LegendEventProcessor extends AbstractEventProcessor {
12081208
existingJob.delayedJob.cancel();
12091209
}
12101210

1211-
// Get the layer
1211+
// Get the layer api
12121212
const layerApi = MapEventProcessor.getMapViewerLayerAPI(mapId);
1213-
const gvLayer = layerApi.getGeoviewLayer(layerPath);
1213+
1214+
// Get the layer if it exists, it's possible it doesn't exist if the layer failed to process
1215+
const gvLayer = layerApi.getGeoviewLayerIfExists(layerPath);
12141216

12151217
// Note the original visibility state of the layer before starting the deletion process.
12161218
// If there was already a pending deletion, preserve its original visibility since the layer is already hidden.
1217-
const originalVisibility = existingJob?.originalVisibility ?? gvLayer.getVisible();
1219+
const originalVisibility = existingJob?.originalVisibility ?? gvLayer?.getVisible() ?? false;
12181220

12191221
// Hide layer immediately
1220-
gvLayer.setVisible(false);
1222+
gvLayer?.setVisible(false);
12211223
layerApi.removeLayerHighlights(layerPath);
12221224

12231225
// Update the store with the start time of the deletion of the layer
@@ -1252,8 +1254,7 @@ export class LegendEventProcessor extends AbstractEventProcessor {
12521254
}
12531255

12541256
// Undo deletion — restore original visibility
1255-
const gvLayerIfExists = layerApi.getGeoviewLayerIfExists(layerPath);
1256-
gvLayerIfExists?.setVisible(originalVisibility);
1257+
gvLayer?.setVisible(originalVisibility);
12571258

12581259
// Negative
12591260
return false;

0 commit comments

Comments
 (0)