Themes: fix conversion for legacy themes

This commit is contained in:
Pieter Vander Vennet 2023-11-19 18:12:43 +01:00
parent 4634ca27ae
commit 21c35fc2c5
2 changed files with 11 additions and 10 deletions

View file

@ -168,8 +168,18 @@ export class UpdateLegacyLayer extends DesugaringStep<
const pr = rendering
if (pr["icon"]) {
try {
const icon = Utils.NoEmpty(pr["icon"].split(";"))
let iconConfig = pr["icon"]
if (
Object.keys(iconConfig).length === 1 &&
iconConfig["render"] !== undefined
) {
iconConfig = iconConfig.render
}
const icon = Utils.NoEmpty(iconConfig.split(";"))
pr.marker = icon.map((i) => {
if (i.startsWith("http")) {
return { icon: i }
}
const [iconPath, color] = i.split(":")
return { icon: iconPath, color }
})
@ -243,10 +253,6 @@ class UpdateLegacyTheme extends DesugaringStep<LayoutConfigJson> {
delete oldThemeConfig.socialImage
}
if (oldThemeConfig.defaultBackgroundId === "osm") {
console.log("Removing old background in", json.id)
}
if (typeof oldThemeConfig.credits === "string") {
oldThemeConfig.credits = [oldThemeConfig.credits]
}

View file

@ -27,11 +27,6 @@ export default class WithContextLoader {
`${translationContext ?? this._context}.${key}.default value`
)
}
if (Object.keys(v).length === 1 && typeof v["render"] === "string") {
throw `At ${
translationContext ?? "<unknown>"
}: use the content directly instead of {${key}: ${JSON.stringify(v)}}`
}
return new TagRenderingConfig(
<QuestionableTagRenderingConfigJson>v,