From 09599e9f153f40e27955ab59a3ab48f209f1dadd Mon Sep 17 00:00:00 2001 From: pietervdvn Date: Sat, 20 Feb 2021 02:25:29 +0100 Subject: [PATCH] Combine dropped the empty elements, causing them not to be able to update --- Models/Constants.ts | 2 +- UI/Base/Combine.ts | 6 +---- UI/Popup/FeatureInfoBox.ts | 45 +++++++++++++++++++------------------- 3 files changed, 24 insertions(+), 29 deletions(-) diff --git a/Models/Constants.ts b/Models/Constants.ts index 7b399c492..1f4599ee1 100644 --- a/Models/Constants.ts +++ b/Models/Constants.ts @@ -2,7 +2,7 @@ import { Utils } from "../Utils"; export default class Constants { - public static vNumber = "0.5.0-rc2"; + public static vNumber = "0.5.0-rc3"; // The user journey states thresholds when a new feature gets unlocked public static userJourney = { diff --git a/UI/Base/Combine.ts b/UI/Base/Combine.ts index 4f5adb74c..827e30e3f 100644 --- a/UI/Base/Combine.ts +++ b/UI/Base/Combine.ts @@ -25,11 +25,7 @@ export default class Combine extends UIElement { console.error("Not a UI-element", ui); return ""; } - let rendered = ui.Render(); - if(ui.IsEmpty()){ - return ""; - } - return rendered; + return ui.Render(); }).join(""); } diff --git a/UI/Popup/FeatureInfoBox.ts b/UI/Popup/FeatureInfoBox.ts index 965876e44..2065485d6 100644 --- a/UI/Popup/FeatureInfoBox.ts +++ b/UI/Popup/FeatureInfoBox.ts @@ -10,6 +10,7 @@ import TagRenderingConfig from "../../Customizations/JSON/TagRenderingConfig"; import ScrollableFullScreen from "../Base/ScrollableFullScreen"; export default class FeatureInfoBox extends UIElement { + private static featureInfoboxCache: Map, FeatureInfoBox>> = new Map, FeatureInfoBox>>(); private _component: ScrollableFullScreen; private constructor( @@ -21,13 +22,25 @@ export default class FeatureInfoBox extends UIElement { if (layerConfig === undefined) { throw "Undefined layerconfig" } - const title = FeatureInfoBox.GenerateTitleBar(tags, layerConfig); - const contents = FeatureInfoBox.GenerateContent(tags, layerConfig); - this._component = new ScrollableFullScreen(title, contents, onClose) + + const title = FeatureInfoBox.GenerateTitleBar(tags, layerConfig); + const contents = FeatureInfoBox.GenerateContent(tags, layerConfig); + this._component = new ScrollableFullScreen(title, contents, onClose); } - - InnerRender(): string { - return this._component.Render(); + + static construct(tags: UIEventSource, layer: LayerConfig, onClose: () => void) { + let innerMap = FeatureInfoBox.featureInfoboxCache.get(layer); + if (innerMap === undefined) { + innerMap = new Map, FeatureInfoBox>(); + FeatureInfoBox.featureInfoboxCache.set(layer, innerMap); + } + + let featureInfoBox = innerMap.get(tags); + if (featureInfoBox === undefined) { + featureInfoBox = new FeatureInfoBox(tags, layer, onClose); + innerMap.set(tags, featureInfoBox); + } + return featureInfoBox; } private static GenerateTitleBar(tags: UIEventSource, @@ -56,8 +69,8 @@ export default class FeatureInfoBox extends UIElement { let questionBoxIsUsed = false; const renderings = layerConfig.tagRenderings.map(tr => { if (tr.question === null) { - questionBoxIsUsed = true; // This is the question box! + questionBoxIsUsed = true; return questionBox; } return new EditableTagRendering(tags, tr); @@ -75,21 +88,7 @@ export default class FeatureInfoBox extends UIElement { } - - - private static featureInfoboxCache : Map, FeatureInfoBox>> = new Map, FeatureInfoBox>>(); - static construct(tags: UIEventSource, layer: LayerConfig, onClose: () => void) { - let innerMap = FeatureInfoBox.featureInfoboxCache.get(layer); - if(innerMap === undefined){ - innerMap = new Map, FeatureInfoBox>(); - FeatureInfoBox.featureInfoboxCache.set(layer, innerMap); - } - - let featureInfoBox = innerMap.get(tags); - if(featureInfoBox === undefined){ - featureInfoBox = new FeatureInfoBox(tags, layer, onClose); - innerMap.set(tags, featureInfoBox); - } - return featureInfoBox; + InnerRender(): string { + return this._component.Render(); } }