From 68d66ffe627ad1ed49e12609f7b990214ac3df9e Mon Sep 17 00:00:00 2001 From: pietervdvn Date: Thu, 8 Jul 2021 10:24:43 +0200 Subject: [PATCH] Fix bug which breaks updates --- Logic/Osm/Changes.ts | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/Logic/Osm/Changes.ts b/Logic/Osm/Changes.ts index ff5de32bf..4a4b00d35 100644 --- a/Logic/Osm/Changes.ts +++ b/Logic/Osm/Changes.ts @@ -136,7 +136,15 @@ export class Changes implements FeatureSource{ } private uploadChangesWithLatestVersions( - knownElements, newElements: OsmObject[], pending: { elementId: string; key: string; value: string }[]) { + knownElements: OsmObject[], newElements: OsmObject[], pending: { elementId: string; key: string; value: string }[]) { + const knownById = new Map(); + + knownElements.forEach(knownElement => { + console.log("Setting ",knownElement.type + knownElement.id, knownElement) + knownById.set(knownElement.type + "/" + knownElement.id, knownElement) + }) + + // Here, inside the continuation, we know that all 'neededIds' are loaded in 'knownElements', which maps the ids onto the elements // We apply the changes on them for (const change of pending) { @@ -147,9 +155,10 @@ export class Changes implements FeatureSource{ newElement.addTag(change.key, change.value); } } - } else { - knownElements[change.elementId].addTag(change.key, change.value); + console.log(knownById, change.elementId) + + knownById.get(change.elementId).addTag(change.key, change.value); } } @@ -230,6 +239,7 @@ export class Changes implements FeatureSource{ neededIds = Utils.Dedup(neededIds); OsmObject.DownloadAll(neededIds).addCallbackAndRunD(knownElements => { + console.log("KnownElements:", knownElements) self.uploadChangesWithLatestVersions(knownElements, newElements, pending) }) }