From 5fd03144080aa32fe500333b64575069e93e8b79 Mon Sep 17 00:00:00 2001 From: Pieter Vander Vennet Date: Tue, 29 Oct 2024 23:53:58 +0100 Subject: [PATCH] Fix: fix uploading images in the 'notes' theme --- src/Logic/ImageProviders/ImageUploadManager.ts | 6 ++++-- src/UI/Image/UploadImage.svelte | 5 ++++- src/UI/SpecialVisualizations.ts | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/Logic/ImageProviders/ImageUploadManager.ts b/src/Logic/ImageProviders/ImageUploadManager.ts index d27613ee3..87108b75c 100644 --- a/src/Logic/ImageProviders/ImageUploadManager.ts +++ b/src/Logic/ImageProviders/ImageUploadManager.ts @@ -10,6 +10,7 @@ import Translations from "../../UI/i18n/Translations" import { Translation } from "../../UI/i18n/Translation" import { IndexedFeatureSource } from "../FeatureSource/FeatureSource" import { GeoOperations } from "../GeoOperations" +import { Feature } from "geojson" /** * The ImageUploadManager has a @@ -155,7 +156,8 @@ export class ImageUploadManager { author: string, blob: File, targetKey: string | undefined, - noblur: boolean + noblur: boolean, + feature?: Feature ): Promise { this.increaseCountFor(this._uploadStarted, featureId) let key: string @@ -166,7 +168,7 @@ export class ImageUploadManager { location = [this._gps.data.longitude, this._gps.data.latitude] } 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) } try { diff --git a/src/UI/Image/UploadImage.svelte b/src/UI/Image/UploadImage.svelte index bf06a9f1c..437adf81a 100644 --- a/src/UI/Image/UploadImage.svelte +++ b/src/UI/Image/UploadImage.svelte @@ -16,6 +16,7 @@ import Camera from "@babeard/svelte-heroicons/solid/Camera" import LayerConfig from "../../Models/ThemeConfig/LayerConfig" import NoteCommentElement from "../Popup/Notes/NoteCommentElement" + import type { Feature } from "geojson" export let state: SpecialVisualizationState @@ -23,6 +24,7 @@ export let targetKey: string = undefined export let layer: LayerConfig export let noBlur: boolean = false + export let feature: Feature = undefined /** * Image to show in the button * NOT the image to upload! @@ -54,7 +56,8 @@ state.osmConnection.userDetails.data?.name ?? "Anonymous", file, "image", - noBlur + noBlur, + feature ) if (!uploadResult) { return diff --git a/src/UI/SpecialVisualizations.ts b/src/UI/SpecialVisualizations.ts index e9b229e18..74206b414 100644 --- a/src/UI/SpecialVisualizations.ts +++ b/src/UI/SpecialVisualizations.ts @@ -1113,7 +1113,7 @@ export default class SpecialVisualizations { constr: (state, tags, args, feature, layer) => { const id = tags.data[args[0] ?? "id"] tags = state.featureProperties.getStore(id) - return new SvelteUIElement(UploadImage, { state, tags, layer }) + return new SvelteUIElement(UploadImage, { state, tags, layer, feature }) }, }, {