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:
Pieter Vander Vennet 2022-06-13 03:13:42 +02:00
parent 3b01e62fbe
commit 7c6e292013
9 changed files with 59 additions and 27 deletions

View file

@ -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"