forked from MapComplete/MapComplete
Quickfix for loading external themes
This commit is contained in:
parent
e404e48f29
commit
848a05a21f
3 changed files with 34 additions and 36 deletions
|
@ -156,17 +156,8 @@ export default class DetermineLayout {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
let parsed = await Utils.downloadJson(link)
|
let parsed = await Utils.downloadJson(link)
|
||||||
console.log("Got ", parsed)
|
|
||||||
parsed = new FixLegacyTheme().convertStrict({
|
|
||||||
tagRenderings: SharedTagRenderings.SharedTagRenderingJson,
|
|
||||||
sharedLayers: new Map<string, LayerConfigJson>() // FIXME: actually add the layers
|
|
||||||
}, parsed, "While loading a dynamic theme")
|
|
||||||
|
|
||||||
|
|
||||||
parsed.id = link;
|
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
parsed.id = link;
|
||||||
const layoutToUse = DetermineLayout.prepCustomTheme(parsed)
|
const layoutToUse = DetermineLayout.prepCustomTheme(parsed)
|
||||||
return new LayoutConfig(layoutToUse,false).patchImages(link, JSON.stringify(layoutToUse));
|
return new LayoutConfig(layoutToUse,false).patchImages(link, JSON.stringify(layoutToUse));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|
|
@ -2,7 +2,7 @@ import {Utils} from "../Utils";
|
||||||
|
|
||||||
export default class Constants {
|
export default class Constants {
|
||||||
|
|
||||||
public static vNumber = "0.14.3";
|
public static vNumber = "0.14.4";
|
||||||
public static ImgurApiKey = '7070e7167f0a25a'
|
public static ImgurApiKey = '7070e7167f0a25a'
|
||||||
public static readonly mapillary_client_token_v4 = "MLY|4441509239301885|b40ad2d3ea105435bd40c7e76993ae85"
|
public static readonly mapillary_client_token_v4 = "MLY|4441509239301885|b40ad2d3ea105435bd40c7e76993ae85"
|
||||||
|
|
||||||
|
|
|
@ -184,7 +184,6 @@ class AddMiniMap extends DesugaringStep<LayerConfigJson> {
|
||||||
convert(state: DesugaringContext, layerConfig: LayerConfigJson, context: string): { result: LayerConfigJson; errors: string[]; warnings: string[] } {
|
convert(state: DesugaringContext, layerConfig: LayerConfigJson, context: string): { result: LayerConfigJson; errors: string[]; warnings: string[] } {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const hasMinimap = layerConfig.tagRenderings?.some(tr => AddMiniMap.hasMinimap(<TagRenderingConfigJson>tr)) ?? true
|
const hasMinimap = layerConfig.tagRenderings?.some(tr => AddMiniMap.hasMinimap(<TagRenderingConfigJson>tr)) ?? true
|
||||||
if (!hasMinimap) {
|
if (!hasMinimap) {
|
||||||
layerConfig = {...layerConfig}
|
layerConfig = {...layerConfig}
|
||||||
|
@ -448,9 +447,13 @@ export class UpdateLegacyLayer extends DesugaringStep<LayerConfigJson | string |
|
||||||
if (typeof json === "string") {
|
if (typeof json === "string") {
|
||||||
return json
|
return json
|
||||||
}
|
}
|
||||||
|
console.log("Updating legacy layer", json)
|
||||||
if (json["builtin"] !== undefined) {
|
if (json["builtin"] !== undefined) {
|
||||||
// @ts-ignore
|
return {
|
||||||
return json;
|
result: json,
|
||||||
|
errors: [],
|
||||||
|
warnings: []
|
||||||
|
};
|
||||||
}
|
}
|
||||||
let config: any = {...json};
|
let config: any = {...json};
|
||||||
|
|
||||||
|
@ -572,6 +575,9 @@ class UpdateLegacyTheme extends DesugaringStep<LayoutConfigJson> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
oldThemeConfig.layers = Utils.NoNull(oldThemeConfig.layers)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
errors: [],
|
errors: [],
|
||||||
warnings: [],
|
warnings: [],
|
||||||
|
@ -943,6 +949,7 @@ class SubstituteLayer extends Conversion<(string | LayerConfigJson), LayerConfig
|
||||||
convert(state: DesugaringContext, json: string | LayerConfigJson, context: string): { result: LayerConfigJson[]; errors: string[]; warnings: string[] } {
|
convert(state: DesugaringContext, json: string | LayerConfigJson, context: string): { result: LayerConfigJson[]; errors: string[]; warnings: string[] } {
|
||||||
const errors = []
|
const errors = []
|
||||||
const warnings = []
|
const warnings = []
|
||||||
|
console.log("Substituting layer ", json)
|
||||||
if (typeof json === "string") {
|
if (typeof json === "string") {
|
||||||
const found = state.sharedLayers.get(json)
|
const found = state.sharedLayers.get(json)
|
||||||
if (found === undefined) {
|
if (found === undefined) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue