Skip to content

Commit

Permalink
Remove non needed if, add comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ivmartel committed Feb 18, 2025
1 parent 684fcf4 commit 8b6fd74
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/app/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -1070,6 +1070,7 @@ export class App {
* @param {ViewConfig} config The view configuration.
*/
updateDataViewConfig(dataId, divId, config) {
// input checks
const configs = this.#options.dataViewConfigs;
// check data id
if (typeof configs[dataId] === 'undefined') {
Expand All @@ -1084,25 +1085,24 @@ export class App {
throw new Error('No config for dataId: ' +
dataId + ' and divId: ' + divId);
}

// update config
const configToUpdate = configs[dataId][itemIndex];
for (const prop in config) {
configToUpdate[prop] = config[prop];
}

// remove previous layers
const lg = this.#stage.getLayerGroupByDivId(configToUpdate.divId);
if (typeof lg !== 'undefined') {
const vls = lg.getViewLayersByDataId(dataId);
// update layer group
const layerGroup = this.#stage.getLayerGroupByDivId(configToUpdate.divId);
if (typeof layerGroup !== 'undefined') {
// remove layer if possible
const vls = layerGroup.getViewLayersByDataId(dataId);
if (vls.length === 1) {
lg.removeLayer(vls[0]);
layerGroup.removeLayer(vls[0]);
}
const dls = lg.getDrawLayersByDataId(dataId);
const dls = layerGroup.getDrawLayersByDataId(dataId);
if (dls.length === 1) {
lg.removeLayer(dls[0]);
}
if (vls.length === 0 && dls.length === 0) {
throw new Error('Expected one layer, got none');
layerGroup.removeLayer(dls[0]);
}
}

Expand Down

0 comments on commit 8b6fd74

Please sign in to comment.