From cd4a2608a27ef78c29a76328ac2e008d8ddaacad Mon Sep 17 00:00:00 2001 From: pietervdvn Date: Thu, 13 May 2021 13:04:17 +0200 Subject: [PATCH] Immediately load and show the selected feature --- Logic/FeatureSource/FilteringFeatureSource.ts | 3 ++- Logic/FeatureSource/OsmApiFeatureSource.ts | 9 ++------- Logic/MetaTagging.ts | 6 ++---- Models/Constants.ts | 2 +- State.ts | 2 +- 5 files changed, 8 insertions(+), 14 deletions(-) diff --git a/Logic/FeatureSource/FilteringFeatureSource.ts b/Logic/FeatureSource/FilteringFeatureSource.ts index e4c8b0f347..dd058198ae 100644 --- a/Logic/FeatureSource/FilteringFeatureSource.ts +++ b/Logic/FeatureSource/FilteringFeatureSource.ts @@ -2,6 +2,7 @@ import FeatureSource from "./FeatureSource"; import {UIEventSource} from "../UIEventSource"; import LayerConfig from "../../Customizations/JSON/LayerConfig"; import Loc from "../../Models/Loc"; +import Hash from "../Web/Hash"; export default class FilteringFeatureSource implements FeatureSource { public features: UIEventSource<{ feature: any; freshness: Date }[]> = new UIEventSource<{ feature: any; freshness: Date }[]>([]); @@ -34,7 +35,7 @@ export default class FilteringFeatureSource implements FeatureSource { const newFeatures = features.filter(f => { const layerId = f.feature._matching_layer_id; - if(selectedElement.data !== undefined && selectedElement.data?.id === f.feature.id){ + if(selectedElement.data?.id === f.feature.id || f.feature.id === Hash.hash.data){ // This is the selected object - it gets a free pass even if zoom is not sufficient return true; } diff --git a/Logic/FeatureSource/OsmApiFeatureSource.ts b/Logic/FeatureSource/OsmApiFeatureSource.ts index 6b01a6755c..8719ffb6ad 100644 --- a/Logic/FeatureSource/OsmApiFeatureSource.ts +++ b/Logic/FeatureSource/OsmApiFeatureSource.ts @@ -11,13 +11,7 @@ export default class OsmApiFeatureSource implements FeatureSource { public readonly name: string = "OsmApiFeatureSource"; private readonly loadedTiles: Set = new Set(); - constructor(location: UIEventSource) { - /* const self = this - location.addCallback(_ => { - self.loadArea() - }) - */ - + constructor() { } @@ -26,6 +20,7 @@ export default class OsmApiFeatureSource implements FeatureSource { // Newly added point - not yet in OSM return; } + console.debug("Downloading", id, "from the OSM-API") OsmObject.DownloadObject(id, (element, meta) => { const geojson = element.asGeoJson(); geojson.id = geojson.properties.id; diff --git a/Logic/MetaTagging.ts b/Logic/MetaTagging.ts index 3c27663da8..2b7d15e2f0 100644 --- a/Logic/MetaTagging.ts +++ b/Logic/MetaTagging.ts @@ -95,9 +95,7 @@ export default class MetaTagging { const f = (featuresPerLayer, feature: any) => { try { - const result = func(feature); - console.debug("Calculated tag with code ", code, " returned ", result) - feature.properties[key] =result; + feature.properties[key] =func(feature); } catch (e) { console.error("Could not calculate a metatag defined by " + code + " due to " + e + ". This is code defined in the theme. Are you the theme creator? Doublecheck your code. Note that the metatags might not be stable on new features") } @@ -114,7 +112,7 @@ export default class MetaTagging { return; } - const relations = params.memberships.get(feature.properties.id) + const relations = params.memberships?.get(feature.properties.id) ?? [] ExtraFunction.FullPatchFeature(params.featuresPerLayer, relations, feature); try { for (const f of functions) { diff --git a/Models/Constants.ts b/Models/Constants.ts index 1d6b053ba3..9b9c66f594 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.7.2a"; + public static vNumber = "0.7.2b"; // The user journey states thresholds when a new feature gets unlocked public static userJourney = { diff --git a/State.ts b/State.ts index 96dbacbeda..8a4922af3f 100644 --- a/State.ts +++ b/State.ts @@ -220,7 +220,7 @@ export default class State { this.allElements = new ElementStorage(); this.changes = new Changes(); - this.osmApiFeatureSource = new OsmApiFeatureSource(this.locationControl) + this.osmApiFeatureSource = new OsmApiFeatureSource() new PendingChangesUploader(this.changes, this.selectedElement);