From 21c35fc2c56eea64d18ee0fc18d65b2cdb913c82 Mon Sep 17 00:00:00 2001 From: Pieter Vander Vennet Date: Sun, 19 Nov 2023 18:12:43 +0100 Subject: [PATCH] Themes: fix conversion for legacy themes --- .../ThemeConfig/Conversion/LegacyJsonConvert.ts | 16 +++++++++++----- src/Models/ThemeConfig/WithContextLoader.ts | 5 ----- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/Models/ThemeConfig/Conversion/LegacyJsonConvert.ts b/src/Models/ThemeConfig/Conversion/LegacyJsonConvert.ts index df4dec4598..3c7cf7efce 100644 --- a/src/Models/ThemeConfig/Conversion/LegacyJsonConvert.ts +++ b/src/Models/ThemeConfig/Conversion/LegacyJsonConvert.ts @@ -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 { delete oldThemeConfig.socialImage } - if (oldThemeConfig.defaultBackgroundId === "osm") { - console.log("Removing old background in", json.id) - } - if (typeof oldThemeConfig.credits === "string") { oldThemeConfig.credits = [oldThemeConfig.credits] } diff --git a/src/Models/ThemeConfig/WithContextLoader.ts b/src/Models/ThemeConfig/WithContextLoader.ts index c00f67edc1..0fee9d6dbf 100644 --- a/src/Models/ThemeConfig/WithContextLoader.ts +++ b/src/Models/ThemeConfig/WithContextLoader.ts @@ -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 ?? "" - }: use the content directly instead of {${key}: ${JSON.stringify(v)}}` - } return new TagRenderingConfig( v,