forked from MapComplete/MapComplete
Studio: do some extra cleaning to prevent corruptions
This commit is contained in:
parent
fb165e1f00
commit
26214ed2a3
1 changed files with 15 additions and 6 deletions
|
@ -297,16 +297,25 @@ export default class EditLayerState extends EditJsonState<LayerConfigJson> {
|
||||||
|
|
||||||
this.addMissingTagRenderingIds()
|
this.addMissingTagRenderingIds()
|
||||||
|
|
||||||
this.configuration.addCallbackAndRunD((layer) => {
|
|
||||||
if (layer.tagRenderings) {
|
function cleanArray(data: object, key: string): boolean{
|
||||||
|
if (data[key]) {
|
||||||
// A bit of cleanup
|
// A bit of cleanup
|
||||||
const lBefore = layer.tagRenderings.length
|
const lBefore = data[key].length
|
||||||
const cleaned = Utils.NoNull(layer.tagRenderings)
|
const cleaned = Utils.NoNull(data[key])
|
||||||
if (cleaned.length != lBefore) {
|
if (cleaned.length != lBefore) {
|
||||||
layer.tagRenderings = cleaned
|
data[key] = cleaned
|
||||||
this.configuration.ping()
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
this.configuration.addCallbackAndRunD((layer) => {
|
||||||
|
const changed = cleanArray(layer, "tagRenderings") || cleanArray(layer, "pointRenderings")
|
||||||
|
if(changed){
|
||||||
|
this.configuration.ping()
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue