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.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() | ||||
|             } | ||||
|         }) | ||||
|     } | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue