forked from MapComplete/MapComplete
		
	Add check for sync-selection mode, fix personal theme by revoking it's special status from 'determine theme', fix #871
This commit is contained in:
		
							parent
							
								
									3b01e62fbe
								
							
						
					
					
						commit
						7c6e292013
					
				
					 9 changed files with 59 additions and 27 deletions
				
			
		|  | @ -2,7 +2,7 @@ import {Utils} from "../Utils"; | |||
| 
 | ||||
| export default class Constants { | ||||
| 
 | ||||
|     public static vNumber = "0.20.1"; | ||||
|     public static vNumber = "0.20.2"; | ||||
|      | ||||
|     public static ImgurApiKey = '7070e7167f0a25a' | ||||
|     public static readonly mapillary_client_token_v4 = "MLY|4441509239301885|b40ad2d3ea105435bd40c7e76993ae85" | ||||
|  | @ -23,7 +23,7 @@ export default class Constants { | |||
|     /** | ||||
|      * Layer IDs of layers which have special properties through built-in hooks | ||||
|      */ | ||||
|     public static readonly priviliged_layers: string[] = [...Constants.added_by_default, "type_node", "note", "import_candidate", ...Constants.no_include] | ||||
|     public static readonly priviliged_layers: string[] = [...Constants.added_by_default, "type_node", "note", "import_candidate", "direction", ...Constants.no_include] | ||||
| 
 | ||||
| 
 | ||||
|     // The user journey states thresholds when a new feature gets unlocked
 | ||||
|  |  | |||
|  | @ -4,7 +4,8 @@ import {Utils} from "../../../Utils"; | |||
| 
 | ||||
| export interface DesugaringContext { | ||||
|     tagRenderings: Map<string, TagRenderingConfigJson> | ||||
|     sharedLayers: Map<string, LayerConfigJson> | ||||
|     sharedLayers: Map<string, LayerConfigJson>, | ||||
|     publicLayers: Set<string> | ||||
| } | ||||
| 
 | ||||
| export abstract class Conversion<TIn, TOut> { | ||||
|  |  | |||
|  | @ -453,9 +453,16 @@ class PreparePersonalTheme extends DesugaringStep<LayoutConfigJson> { | |||
|         if (json.id !== "personal") { | ||||
|             return {result: json} | ||||
|         } | ||||
|          | ||||
|         // The only thing this _really_ does, is adding the layer-ids into 'layers'
 | ||||
|         // All other preparations are done by the 'override-all'-block in personal.json
 | ||||
| 
 | ||||
|         json.layers = Array.from(this._state.sharedLayers.keys()).filter(l => Constants.priviliged_layers.indexOf(l) < 0) | ||||
|         return {result: json}; | ||||
|         json.layers = Array.from(this._state.sharedLayers.keys()) | ||||
|             .filter(l => Constants.priviliged_layers.indexOf(l) < 0) | ||||
|             .filter(l => this._state.publicLayers.has(l)) | ||||
|         return {result: json, information: [ | ||||
|             "The personal theme has "+json.layers.length+" public layers" | ||||
|             ]}; | ||||
|     } | ||||
| 
 | ||||
| } | ||||
|  |  | |||
|  | @ -426,7 +426,7 @@ export interface LayerConfigJson { | |||
|     units?: UnitConfigJson[] | ||||
| 
 | ||||
|     /** | ||||
|      * If set, synchronizes wether or not this layer is selected. | ||||
|      * If set, synchronizes whether or not this layer is enabled. | ||||
|      * | ||||
|      * no: Do not sync at all, always revert to default | ||||
|      * local: keep selection on local storage | ||||
|  |  | |||
|  | @ -65,7 +65,8 @@ export default class LayerConfig extends WithContextLoader { | |||
|     public readonly filterIsSameAs: string; | ||||
|     public readonly forceLoad: boolean; | ||||
| 
 | ||||
|     public readonly syncSelection: "no" | "local" | "theme-only" | "global" | ||||
|     public static readonly syncSelectionAllowed =  ["no" , "local" , "theme-only" , "global"] as const; | ||||
|     public readonly syncSelection: (typeof LayerConfig.syncSelectionAllowed)[number] // this is a trick to conver a constant array of strings into a type union of these values
 | ||||
| 
 | ||||
|     constructor( | ||||
|         json: LayerConfigJson, | ||||
|  | @ -97,7 +98,10 @@ export default class LayerConfig extends WithContextLoader { | |||
|         } | ||||
| 
 | ||||
|         this.maxAgeOfCache = json.source.maxCacheAge ?? 24 * 60 * 60 * 30 | ||||
|         this.syncSelection = json.syncSelection; | ||||
|         if(json.syncSelection !== undefined && LayerConfig.syncSelectionAllowed.indexOf(json.syncSelection) < 0){ | ||||
|             throw context+ " Invalid sync-selection: must be one of "+LayerConfig.syncSelectionAllowed.map(v => `'${v}'`).join(", ")+" but got '"+json.syncSelection+"'" | ||||
|         } | ||||
|         this.syncSelection = json.syncSelection ?? "no"; | ||||
|         const osmTags = TagUtils.Tag( | ||||
|             json.source.osmTags, | ||||
|             context + "source.osmTags" | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue