Studio: do some extra cleaning to prevent corruptions

This commit is contained in:
Pieter Vander Vennet 2023-12-03 03:01:43 +01:00
parent fb165e1f00
commit 26214ed2a3

View file

@ -297,16 +297,25 @@ export default class EditLayerState extends EditJsonState<LayerConfigJson> {
this.addMissingTagRenderingIds()
this.configuration.addCallbackAndRunD((layer) => {
if (layer.tagRenderings) {
function cleanArray(data: object, key: string): boolean{
if (data[key]) {
// A bit of cleanup
const lBefore = layer.tagRenderings.length
const cleaned = Utils.NoNull(layer.tagRenderings)
const lBefore = data[key].length
const cleaned = Utils.NoNull(data[key])
if (cleaned.length != lBefore) {
layer.tagRenderings = cleaned
this.configuration.ping()
data[key] = cleaned
return true
}
}
return false
}
this.configuration.addCallbackAndRunD((layer) => {
const changed = cleanArray(layer, "tagRenderings") || cleanArray(layer, "pointRenderings")
if(changed){
this.configuration.ping()
}
})
}