From 5214d76f46f269e9da3d46cb65ce8719bb20cbb4 Mon Sep 17 00:00:00 2001 From: Sam Becker Date: Thu, 14 Mar 2024 09:12:04 -0500 Subject: [PATCH] Show updated titles while updating/creating photos --- src/photo/PhotoEditPageClient.tsx | 6 +++++- src/photo/UploadPageClient.tsx | 6 +++++- src/photo/form/PhotoForm.tsx | 7 ++++++- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/photo/PhotoEditPageClient.tsx b/src/photo/PhotoEditPageClient.tsx index 9e298eed..6be696f5 100644 --- a/src/photo/PhotoEditPageClient.tsx +++ b/src/photo/PhotoEditPageClient.tsx @@ -28,6 +28,7 @@ export default function PhotoEditPageClient({ ); const [pending, setIsPending] = useState(false); + const [updatedTitle, setUpdatedTitle] = useState(''); const hasExifDataBeenFound = !areSimpleObjectsEqual( updatedExifData, @@ -38,7 +39,9 @@ export default function PhotoEditPageClient({ @@ -59,6 +62,7 @@ export default function PhotoEditPageClient({ ? updatedExifData : undefined} uniqueTags={uniqueTags} + onTitleChange={setUpdatedTitle} onFormStatusChange={setIsPending} /> diff --git a/src/photo/UploadPageClient.tsx b/src/photo/UploadPageClient.tsx index cd17670a..b37a4d39 100644 --- a/src/photo/UploadPageClient.tsx +++ b/src/photo/UploadPageClient.tsx @@ -17,17 +17,21 @@ export default function UploadPageClient({ uniqueTags: Tags }) { const [pending, setIsPending] = useState(false); + const [updatedTitle, setUpdatedTitle] = useState(''); return ( diff --git a/src/photo/form/PhotoForm.tsx b/src/photo/form/PhotoForm.tsx index d26d22a8..8db158c1 100644 --- a/src/photo/form/PhotoForm.tsx +++ b/src/photo/form/PhotoForm.tsx @@ -34,6 +34,7 @@ export default function PhotoForm({ type = 'create', uniqueTags, debugBlur, + onTitleChange, onFormStatusChange, }: { initialPhotoForm: Partial @@ -41,6 +42,7 @@ export default function PhotoForm({ type?: 'create' | 'edit' uniqueTags?: Tags debugBlur?: boolean + onTitleChange?: (updatedTitle: string) => void onFormStatusChange?: (pending: boolean) => void }) { const [formData, setFormData] = @@ -86,7 +88,7 @@ export default function PhotoForm({ } = getDimensionsFromSize(THUMBNAIL_SIZE, formData.aspectRatio); // Generate local date strings when - // none can be harvested from EXIF + // none can be extracted from EXIF useEffect(() => { if (!formData.takenAt || !formData.takenAtNaive) { setFormData(data => ({ @@ -188,6 +190,9 @@ export default function PhotoForm({ if (validate) { setFormErrors({ ...formErrors, [key]: validate(value) }); } + if (key === 'title') { + onTitleChange?.(value.trim()); + } }} selectOptions={selectOptions} selectOptionsDefaultLabel={selectOptionsDefaultLabel}