Improve updating of metatagging

This commit is contained in:
Pieter Vander Vennet 2024-06-01 12:49:25 +02:00
parent 35d863180a
commit fc667f4d47

View file

@ -84,7 +84,8 @@ export default class MetaTagging {
const tags = state?.featureProperties?.getStore(feature.properties.id) const tags = state?.featureProperties?.getStore(feature.properties.id)
console.log("Binding an updater to", feature) console.log("Binding an updater to", feature)
tags?.addCallbackD(() => { tags?.addCallbackD(() => {
console.log("Received an update!") console.log("Received an update! Re-calculating the metatags")
if(feature !== state.selectedElement.data){ if(feature !== state.selectedElement.data){
return true // Unregister, we are not the selected element anymore return true // Unregister, we are not the selected element anymore
} }
@ -107,7 +108,7 @@ export default class MetaTagging {
* Triggers an update of the calculated tags of the selected element * Triggers an update of the calculated tags of the selected element
* @private * @private
*/ */
private updateCurrentSelectedElement() { private updateCurrentSelectedElement(lightUpdate = false) {
const feature = this.state.selectedElement.data const feature = this.state.selectedElement.data
if (!feature) { if (!feature) {
return return
@ -123,7 +124,8 @@ export default class MetaTagging {
state.osmObjectDownloader, state.osmObjectDownloader,
state.featureProperties, state.featureProperties,
{ {
evaluateStrict: true includeDates: !lightUpdate,
evaluateStrict: !lightUpdate
} }
) )
} }
@ -207,8 +209,12 @@ export default class MetaTagging {
// All keys are defined - lets skip! // All keys are defined - lets skip!
continue continue
} }
const shouldPing = metatag.applyMetaTagsOnFeature(feature, layer, tags, state)
if(!shouldPing){
continue
}
somethingChanged = true somethingChanged = true
metatag.applyMetaTagsOnFeature(feature, layer, tags, state)
if (options?.evaluateStrict) { if (options?.evaluateStrict) {
for (const key of metatag.keys) { for (const key of metatag.keys) {
// Important: we _have_ to evaluate this as this might trigger a calculation // Important: we _have_ to evaluate this as this might trigger a calculation