diff --git a/src/Logic/FeatureSource/Actors/FeaturePropertiesStore.ts b/src/Logic/FeatureSource/Actors/FeaturePropertiesStore.ts index e99398f230..47fd12b2de 100644 --- a/src/Logic/FeatureSource/Actors/FeaturePropertiesStore.ts +++ b/src/Logic/FeatureSource/Actors/FeaturePropertiesStore.ts @@ -1,6 +1,5 @@ import { FeatureSource } from "../FeatureSource" import { UIEventSource } from "../../UIEventSource" -import { OsmTags } from "../../../Models/OsmFeature" /** * Constructs a UIEventStore for the properties of every Feature, indexed by id @@ -58,7 +57,7 @@ export default class FeaturePropertiesStore { return store } - public trackFeature(feature: { properties: OsmTags }) { + public trackFeature(feature: { properties: Record }) { const id = feature.properties.id if (id === undefined) { console.trace("Error: feature without ID:", feature) @@ -67,7 +66,7 @@ export default class FeaturePropertiesStore { const source = this._elements.get(id) if (source === undefined) { - this._elements.set(id, new UIEventSource(feature.properties)) + this._elements.set(id, new UIEventSource>(feature.properties)) return } diff --git a/src/Logic/ImageProviders/ImageUploadManager.ts b/src/Logic/ImageProviders/ImageUploadManager.ts index 08971c1217..fffa82456a 100644 --- a/src/Logic/ImageProviders/ImageUploadManager.ts +++ b/src/Logic/ImageProviders/ImageUploadManager.ts @@ -222,7 +222,8 @@ export class ImageUploadManager { this._queue.delete(args) return } - properties = new UIEventSource(downloaded.tags) + this._featureProperties.trackFeature(downloaded.asGeoJson()) + properties = this._featureProperties.getStore(args.featureId) } const action = new LinkImageAction( args.featureId, diff --git a/src/Logic/ImageProviders/ImageUploadQueue.ts b/src/Logic/ImageProviders/ImageUploadQueue.ts index de3aa8cf75..5239f97eba 100644 --- a/src/Logic/ImageProviders/ImageUploadQueue.ts +++ b/src/Logic/ImageProviders/ImageUploadQueue.ts @@ -2,7 +2,7 @@ import { IdbLocalStorage } from "../Web/IdbLocalStorage" import { Store, UIEventSource } from "../UIEventSource" export interface ImageUploadArguments { - readonly featureId: string, + featureId: string, readonly author: string, readonly blob: File, readonly targetKey: string | undefined, @@ -43,4 +43,17 @@ export default class ImageUploadQueue { this._imagesInQueue.ping() } + applyRemapping(oldId: string, newId: string) { + + let hasChange = false + for (const img of this._imagesInQueue.data) { + if (img.featureId === oldId) { + img.featureId = newId + hasChange = true + } + } + if (hasChange) { + this._imagesInQueue.ping() + } + } } diff --git a/src/Logic/Osm/ChangesetHandler.ts b/src/Logic/Osm/ChangesetHandler.ts index ac1f386e24..da38c67fd4 100644 --- a/src/Logic/Osm/ChangesetHandler.ts +++ b/src/Logic/Osm/ChangesetHandler.ts @@ -7,6 +7,7 @@ import { Changes } from "./Changes" import { Utils } from "../../Utils" import FeaturePropertiesStore from "../FeatureSource/Actors/FeaturePropertiesStore" import { AndroidPolyfill } from "../Web/AndroidPolyfill" +import ImageUploadQueue from "../ImageProviders/ImageUploadQueue" export interface ChangesetTag { key: string @@ -358,7 +359,8 @@ export class ChangesetHandler { const [oldId, newId] = mapping this.allElements?.addAlias(oldId, newId) if (newId !== undefined) { - this._remappings.set(mapping[0], mapping[1]) + this._remappings.set(oldId, newId) + ImageUploadQueue.singleton.applyRemapping(oldId, newId) } } return new Map(mappings)