Fix: quickfixes to image upload flow

This commit is contained in:
Pieter Vander Vennet 2024-09-28 12:01:10 +02:00
parent ce363dfb59
commit ba1eb28f27
3 changed files with 12 additions and 9 deletions

View file

@ -7,7 +7,6 @@ import { Store, UIEventSource } from "../UIEventSource"
import { OsmConnection } from "../Osm/OsmConnection"
import { Changes } from "../Osm/Changes"
import Translations from "../../UI/i18n/Translations"
import NoteCommentElement from "../../UI/Popup/Notes/NoteCommentElement"
import { Translation } from "../../UI/i18n/Translation"
import { IndexedFeatureSource } from "../FeatureSource/FeatureSource"
import { GeoOperations } from "../GeoOperations"
@ -136,7 +135,7 @@ export class ImageUploadManager {
}
public async uploadImageWithLicense(
featureId: OsmId,
featureId: string,
author: string,
blob: File,
targetKey: string | undefined,

View file

@ -5,7 +5,7 @@
import type { SpecialVisualizationState } from "../SpecialVisualization"
import { ImmutableStore, UIEventSource } from "../../Logic/UIEventSource"
import type { OsmTags } from "../../Models/OsmFeature"
import type { OsmId, OsmTags } from "../../Models/OsmFeature"
import LoginToggle from "../Base/LoginToggle.svelte"
import Translations from "../i18n/Translations"
import Tr from "../Base/Tr.svelte"
@ -47,22 +47,25 @@
continue
}
if(layer.id === "note"){
const uploadResult = await state?.imageUploadManager.uploadImageWithLicense(file, tags, targetKey)
if(layer?.id === "note"){
const uploadResult = await state?.imageUploadManager.uploadImageWithLicense(tags.data.id,
state.osmConnection.userDetails.data?.name ?? "Anonymous",
file, "image")
if(!uploadResult){
return
}
const url = uploadResult.absoluteUrl
await this._osmConnection.addCommentToNote(tags.data.id, url)
await state.osmConnection.addCommentToNote(tags.data.id, url)
NoteCommentElement.addCommentTo(url, <UIEventSource<any>>tags, {
osmConnection: this._osmConnection,
osmConnection: state.osmConnection,
})
return
}
await state?.imageUploadManager.uploadImageAndApply(file, tags, targetKey)
} catch (e) {
alert(e)
console.error(e)
state.reportError(e, "Could not upload image")
}
}
errors.setData(errs)

View file

@ -88,7 +88,8 @@ export interface SpecialVisualizationState {
readonly geocodedImages : UIEventSource<Feature[]>
showCurrentLocationOn(map: Store<MlMap>): ShowDataLayer
reportError(message: string): Promise<void>
reportError(message: string | Error | XMLHttpRequest, extramessage?: string): Promise<void>
}
export interface SpecialVisualization {