Fix: fix uploading images in the 'notes' theme

This commit is contained in:
Pieter Vander Vennet 2024-10-29 23:53:58 +01:00
parent e4b75c1681
commit 5fd0314408
3 changed files with 9 additions and 4 deletions

View file

@ -10,6 +10,7 @@ import Translations from "../../UI/i18n/Translations"
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"
import { Feature } from "geojson"
/** /**
* The ImageUploadManager has a * The ImageUploadManager has a
@ -155,7 +156,8 @@ export class ImageUploadManager {
author: string, author: string,
blob: File, blob: File,
targetKey: string | undefined, targetKey: string | undefined,
noblur: boolean noblur: boolean,
feature?: Feature
): Promise<UploadResult> { ): Promise<UploadResult> {
this.increaseCountFor(this._uploadStarted, featureId) this.increaseCountFor(this._uploadStarted, featureId)
let key: string let key: string
@ -166,7 +168,7 @@ export class ImageUploadManager {
location = [this._gps.data.longitude, this._gps.data.latitude] location = [this._gps.data.longitude, this._gps.data.latitude]
} }
if (location === undefined || location?.some((l) => l === undefined)) { if (location === undefined || location?.some((l) => l === undefined)) {
const feature = this._indexedFeatures.featuresById.data.get(featureId) feature ??= this._indexedFeatures.featuresById.data.get(featureId)
location = GeoOperations.centerpointCoordinates(feature) location = GeoOperations.centerpointCoordinates(feature)
} }
try { try {

View file

@ -16,6 +16,7 @@
import Camera from "@babeard/svelte-heroicons/solid/Camera" import Camera from "@babeard/svelte-heroicons/solid/Camera"
import LayerConfig from "../../Models/ThemeConfig/LayerConfig" import LayerConfig from "../../Models/ThemeConfig/LayerConfig"
import NoteCommentElement from "../Popup/Notes/NoteCommentElement" import NoteCommentElement from "../Popup/Notes/NoteCommentElement"
import type { Feature } from "geojson"
export let state: SpecialVisualizationState export let state: SpecialVisualizationState
@ -23,6 +24,7 @@
export let targetKey: string = undefined export let targetKey: string = undefined
export let layer: LayerConfig export let layer: LayerConfig
export let noBlur: boolean = false export let noBlur: boolean = false
export let feature: Feature = undefined
/** /**
* Image to show in the button * Image to show in the button
* NOT the image to upload! * NOT the image to upload!
@ -54,7 +56,8 @@
state.osmConnection.userDetails.data?.name ?? "Anonymous", state.osmConnection.userDetails.data?.name ?? "Anonymous",
file, file,
"image", "image",
noBlur noBlur,
feature
) )
if (!uploadResult) { if (!uploadResult) {
return return

View file

@ -1113,7 +1113,7 @@ export default class SpecialVisualizations {
constr: (state, tags, args, feature, layer) => { constr: (state, tags, args, feature, layer) => {
const id = tags.data[args[0] ?? "id"] const id = tags.data[args[0] ?? "id"]
tags = state.featureProperties.getStore(id) tags = state.featureProperties.getStore(id)
return new SvelteUIElement(UploadImage, { state, tags, layer }) return new SvelteUIElement(UploadImage, { state, tags, layer, feature })
}, },
}, },
{ {