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

View file

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

View file

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