forked from MapComplete/MapComplete
Feature(imagequeue): (hopefully) handle some edge cases correctly
This commit is contained in:
parent
6925b3d26e
commit
aa373ee698
4 changed files with 21 additions and 6 deletions
|
@ -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<string, string> }) {
|
||||
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<any>(feature.properties))
|
||||
this._elements.set(id, new UIEventSource<Record<string, string>>(feature.properties))
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<string, string>(mappings)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue