Skip to content

Add photos to elements#30

Merged
dfalling merged 1 commit into
mainfrom
add-element-photos
Jun 4, 2026
Merged

Add photos to elements#30
dfalling merged 1 commit into
mainfrom
add-element-photos

Conversation

@dfalling
Copy link
Copy Markdown
Owner

@dfalling dfalling commented Jun 4, 2026

Summary

  • Add a Photos section to the element edit screen: pick from the device library, with add/remove thumbnails. Selected ids are sent as the element's complete photoIds set on save, so the one flow covers add/remove/reorder.
  • On-device downsampling: every photo is re-encoded to JPEG and looped down in dimensions/quality until it's under the server's 5 MB cap (the resizer reports byte size, so the cap is guaranteed). Normalizing to JPEG also avoids HEIC/PNG the server may reject.
  • Implements the three-step upload in src/photos/photoUpload.ts (usePhotoUploader): createUploadUrlPUT bytes to S3 → createPhoto({type: S3, storageKey}).
  • Adds react-native-image-picker + @bam.tech/react-native-image-resizer (both autolink for Android) and mocks them in jest.setup.js.
  • Regenerates GraphQL types against the current schema — this also picks up the createS3Photo/createUnsplashPhotocreatePhoto consolidation that had drifted out of the committed types.

Notes

  • Requires a native rebuild (bun run android) since native modules were added; library selection uses the Android system photo picker, so no new manifest permissions.
  • Upload Content-Type is set to image/jpeg; adjust in putToSignedUrl if the server's presigned PUT binds a different content type.
  • The Photo record is created at pick-time, so uploading then cancelling the edit without saving leaves an unattached photo server-side (harmless orphan).

🤖 Generated with Claude Code

Lets users attach photos to an element from the edit screen. Photos are
picked from the device library, downsampled on-device to stay under the
server's 5 MB cap (re-encoded to JPEG via a dimension/quality loop), then
run through the three-step upload: signed URL -> PUT to S3 -> createPhoto.
The resulting ids are sent as the element's complete photoIds set on save,
so the same flow handles adding, removing, and reordering.

Regenerates GraphQL types against the current schema, which also picks up
the createS3Photo/createUnsplashPhoto -> createPhoto consolidation that had
drifted out of the committed types.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@dfalling dfalling merged commit 97aca0c into main Jun 4, 2026
2 checks passed
@dfalling dfalling deleted the add-element-photos branch June 4, 2026 15:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant