Disable next button while uploading photos

This commit is contained in:
MartinBraquet
2026-03-09 21:57:07 +01:00
parent 6aae66f0d2
commit 93e6b18b49
2 changed files with 7 additions and 1 deletions

View File

@@ -58,6 +58,7 @@ export const OptionalProfileUserForm = (props: {
const {profile, user, buttonLabel, setProfile, onSubmit, bottomNavBarVisible = true} = props
const [isSubmitting, setIsSubmitting] = useState(false)
const [uploadingImages, setUploadingImages] = useState(false)
const [lookingRelationship, setLookingRelationship] = useState(
(profile.pref_relation_styles || []).includes('relationship'),
)
@@ -1003,6 +1004,7 @@ export const OptionalProfileUserForm = (props: {
})
}
image_descriptions={profile.image_descriptions as Record<string, string>}
onUpload={(uploading) => setUploadingImages(uploading)}
/>
</Col>
@@ -1014,7 +1016,7 @@ export const OptionalProfileUserForm = (props: {
? 'bottom-[calc(90px+var(--bnh))]'
: 'bottom-[calc(30px+var(--bnh))]',
)}
disabled={isSubmitting}
disabled={isSubmitting || uploadingImages}
loading={isSubmitting}
onClick={handleSubmit}
color={'gray'}

View File

@@ -19,6 +19,7 @@ export const AddPhotosWidget = (props: {
setPhotoUrls: (urls: string[]) => void
setPinnedUrl: (url: string) => void
setDescription: (url: string, description: string) => void
onUpload?: (uploading: boolean) => void
}) => {
const {
username,
@@ -28,6 +29,7 @@ export const AddPhotosWidget = (props: {
setPinnedUrl,
setDescription,
image_descriptions,
onUpload,
} = props
const t = useT()
@@ -37,6 +39,7 @@ export const AddPhotosWidget = (props: {
const files = e.target.files
if (!files) return
setUploadingImages(true)
onUpload?.(true)
// Convert files to an array and take only the first 6 files
const selectedFiles = Array.from(files).slice(0, 6)
@@ -50,6 +53,7 @@ export const AddPhotosWidget = (props: {
if (!pinned_url) setPinnedUrl(urls[0])
setPhotoUrls(uniq([...(photo_urls ?? []), ...urls]))
setUploadingImages(false)
onUpload?.(false)
}
return (