From 65470cbac54009aed249d8b5af74a84d331787fd Mon Sep 17 00:00:00 2001 From: pietervdvn Date: Mon, 4 Oct 2021 00:18:08 +0200 Subject: [PATCH] Fix bug where metatagging would not fully calculate in some cases --- Logic/FeatureSource/FeaturePipeline.ts | 7 ++++--- Logic/MetaTagging.ts | 10 +++++++++- Logic/SimpleMetaTagger.ts | 10 +++++----- UI/Base/MinimapImplementation.ts | 2 +- UI/BigComponents/UserBadge.ts | 2 +- css/index-tailwind-output.css | 18 ++++++++++++------ css/wikipedia.css | 2 +- index.ts | 3 +-- 8 files changed, 34 insertions(+), 20 deletions(-) diff --git a/Logic/FeatureSource/FeaturePipeline.ts b/Logic/FeatureSource/FeaturePipeline.ts index 0dff975442..3aa0af3562 100644 --- a/Logic/FeatureSource/FeaturePipeline.ts +++ b/Logic/FeatureSource/FeaturePipeline.ts @@ -353,20 +353,21 @@ export default class FeaturePipeline { private applyMetaTags(src: FeatureSourceForLayer) { const self = this - console.debug("Applying metatagging onto ", src.name) window.setTimeout( () => { + console.debug("Applying metatagging onto ", src.name) + const layerDef = src.layer.layerDef; MetaTagging.addMetatags( src.features.data, { memberships: this.relationTracker, getFeaturesWithin: (layerId, bbox: BBox) => self.GetFeaturesWithin(layerId, bbox) }, - src.layer.layerDef, + layerDef, { includeDates: true, // We assume that the non-dated metatags are already set by the cache generator - includeNonDates: !src.layer.layerDef.source.isOsmCacheLayer + includeNonDates: layerDef.source.geojsonSource === undefined || !layerDef.source.isOsmCacheLayer } ) }, diff --git a/Logic/MetaTagging.ts b/Logic/MetaTagging.ts index 47d7f8a357..9f96e77309 100644 --- a/Logic/MetaTagging.ts +++ b/Logic/MetaTagging.ts @@ -61,7 +61,15 @@ export default class MetaTagging { // All keys are already defined, we probably already ran this one continue } - somethingChanged = somethingChanged || metatag.applyMetaTagsOnFeature(feature, freshness) + const newValueAdded = metatag.applyMetaTagsOnFeature(feature, freshness) + /* Note that the expression: + * `somethingChanged = newValueAdded || metatag.applyMetaTagsOnFeature(feature, freshness)` + * Is WRONG + * + * IF something changed is `true` due to an earlier run, it will short-circuit and _not_ evaluate the right hand of the OR, + * thus not running an update! + */ + somethingChanged = newValueAdded || somethingChanged } catch (e) { console.error("Could not calculate metatag for ", metatag.keys.join(","), ":", e, e.stack) } diff --git a/Logic/SimpleMetaTagger.ts b/Logic/SimpleMetaTagger.ts index eb1a6a49d8..2845223f8d 100644 --- a/Logic/SimpleMetaTagger.ts +++ b/Logic/SimpleMetaTagger.ts @@ -146,14 +146,14 @@ export default class SimpleMetaTagger { private static country = new SimpleMetaTagger( { keys: ["_country"], - doc: "The country code of the property (with latlon2country)" + doc: "The country code of the property (with latlon2country)", + includesDates: false }, - feature => { - + ((feature, _) => { let centerPoint: any = GeoOperations.centerpoint(feature); const lat = centerPoint.geometry.coordinates[1]; const lon = centerPoint.geometry.coordinates[0]; - + SimpleMetaTagger.coder?.GetCountryCodeFor(lon, lat, (countries: string[]) => { try { const oldCountry = feature.properties["_country"]; @@ -167,7 +167,7 @@ export default class SimpleMetaTagger { } }) return false; - } + }) ) private static isOpen = new SimpleMetaTagger( { diff --git a/UI/Base/MinimapImplementation.ts b/UI/Base/MinimapImplementation.ts index 110235437a..9ec90bd313 100644 --- a/UI/Base/MinimapImplementation.ts +++ b/UI/Base/MinimapImplementation.ts @@ -118,7 +118,7 @@ export default class MinimapImplementation extends BaseUIElement implements Mini self.InitMap(); self.leafletMap?.data?.invalidateSize() } catch (e) { - console.error("Could not construct a minimap:", e) + console.warn("Could not construct a minimap:", e) } }); diff --git a/UI/BigComponents/UserBadge.ts b/UI/BigComponents/UserBadge.ts index 3aef14044c..f16d1c5f6e 100644 --- a/UI/BigComponents/UserBadge.ts +++ b/UI/BigComponents/UserBadge.ts @@ -133,7 +133,7 @@ export default class UserBadge extends Toggle { ) - this.SetClass("shadow rounded-full h-min overflow-hidden block w-max") + this.SetClass("shadow rounded-full h-min overflow-hidden block w-full md:w-max") } diff --git a/css/index-tailwind-output.css b/css/index-tailwind-output.css index adb7b1ee9b..0549527564 100644 --- a/css/index-tailwind-output.css +++ b/css/index-tailwind-output.css @@ -1062,12 +1062,6 @@ video { width: min-content; } -.w-max { - width: -webkit-max-content; - width: -moz-max-content; - width: max-content; -} - .w-6 { width: 1.5rem; } @@ -1076,6 +1070,12 @@ video { width: 50%; } +.w-max { + width: -webkit-max-content; + width: -moz-max-content; + width: max-content; +} + .min-w-min { min-width: -webkit-min-content; min-width: -moz-min-content; @@ -2339,6 +2339,12 @@ li::marker { width: auto; } + .md\:w-max { + width: -webkit-max-content; + width: -moz-max-content; + width: max-content; + } + .md\:grid-flow-row { grid-auto-flow: row; } diff --git a/css/wikipedia.css b/css/wikipedia.css index 99d25c4373..e636fb8dc2 100644 --- a/css/wikipedia.css +++ b/css/wikipedia.css @@ -9,7 +9,7 @@ clear: right; } -.wikipedia-article svg, img { +.wikipedia-article svg, .wikipedia-article img { width: unset; height: unset; display: unset; diff --git a/index.ts b/index.ts index 1e98ae890b..e5e58a6f0a 100644 --- a/index.ts +++ b/index.ts @@ -19,8 +19,7 @@ import SimpleMetaTagger from "./Logic/SimpleMetaTagger"; MinimapImplementation.initialize() // Workaround for a stupid crash: inject some functions which would give stupid circular dependencies or crash the other nodejs scripts ValidatedTextField.bestLayerAt = (location, layerPref) => AvailableBaseLayers.SelectBestLayerAccordingTo(location, layerPref) - - SimpleMetaTagger.coder = new CountryCoder("https://pietervdvn.github.io/latlon2country/"); +SimpleMetaTagger.coder = new CountryCoder("https://pietervdvn.github.io/latlon2country/"); let defaultLayout = "" // --------------------- Special actions based on the parameters -----------------