From 4468e832bfca974358d47ef3a1acca074fb98e4e Mon Sep 17 00:00:00 2001 From: "Muhammad A. Ghorbani" Date: Sat, 12 Sep 2026 16:24:01 +0330 Subject: [PATCH] feat: add QuestionPhoto component for image uploads and previews --- src/components/Componentes/question-photo.tsx | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/components/Componentes/question-photo.tsx b/src/components/Componentes/question-photo.tsx index 97f6b9a..1d84377 100644 --- a/src/components/Componentes/question-photo.tsx +++ b/src/components/Componentes/question-photo.tsx @@ -92,11 +92,15 @@ export function QuestionPhoto({ if (fileInputRef.current) { fileInputRef.current.value = ""; } - setToastMessage( - t["Failed to load image. Please try uploading again."] ?? - "Failed to load image. Please try uploading again.", - ); - }, [question, setAnswerValue, t]); + // Only show the toast if the user was actively uploading; + // stale stored URLs from previous sessions fail silently. + if (isUploading || isInitiatorRef.current) { + setToastMessage( + t["Failed to load image. Please try uploading again."] ?? + "Failed to load image. Please try uploading again.", + ); + } + }, [question, setAnswerValue, t, isUploading]); const uploadTmpMediaMutation = useUploadTmpMediaMutation({ onSuccess: (response) => { @@ -256,8 +260,7 @@ export function QuestionPhoto({ mediaType: "image", source: pickerSource as any, picker_type: pickerType as any, - returnAs: "upload", - uploadUrl: `${window.location.origin}/api/proxy?__proxyPath=/upload-tmp-media/`, + returnAs: "base64", fieldName: "file", allowedExtensions: extensions.length > 0 ? extensions : ["jpg", "jpeg", "png", "webp"],