Skip to content

Commit 97aca0c

Browse files
dfallingclaude
andauthored
Add photos to elements (#30)
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>
1 parent d8b0691 commit 97aca0c

8 files changed

Lines changed: 435 additions & 26 deletions

File tree

bun.lock

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

jest.setup.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,21 @@ jest.mock('react-native-encrypted-storage', () => ({
88
},
99
}));
1010

11+
jest.mock('react-native-image-picker', () => ({
12+
__esModule: true,
13+
launchImageLibrary: jest.fn(() => Promise.resolve({didCancel: true})),
14+
launchCamera: jest.fn(() => Promise.resolve({didCancel: true})),
15+
}));
16+
17+
jest.mock('@bam.tech/react-native-image-resizer', () => ({
18+
__esModule: true,
19+
default: {
20+
createResizedImage: jest.fn(() =>
21+
Promise.resolve({uri: 'file:///resized.jpg', size: 1024}),
22+
),
23+
},
24+
}));
25+
1126
jest.mock('@maplibre/maplibre-react-native', () => {
1227
const React = require('react');
1328
const passthrough = name => {

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
},
1515
"dependencies": {
1616
"@apollo/client": "^3.11.0",
17+
"@bam.tech/react-native-image-resizer": "^3.0.11",
1718
"@maplibre/maplibre-react-native": "^11.2.1",
1819
"@react-native/new-app-screen": "0.85.3",
1920
"@react-navigation/native": "^7.2.5",
@@ -22,6 +23,7 @@
2223
"react": "19.2.3",
2324
"react-native": "0.85.3",
2425
"react-native-encrypted-storage": "^4.0.3",
26+
"react-native-image-picker": "^8.2.1",
2527
"react-native-safe-area-context": "^5.5.2",
2628
"react-native-screens": "^4.25.2",
2729
"rn-emoji-keyboard": "^1.7.0"

src/graphql/__generated__/types.ts

Lines changed: 130 additions & 25 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
mutation CreatePhoto($input: PhotoInput!) {
2+
createPhoto(input: $input) {
3+
id
4+
thumbnail
5+
regular
6+
description
7+
}
8+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
query CreateUploadUrl($bustCache: Int) {
2+
createUploadUrl(bustCache: $bustCache) {
3+
url
4+
key
5+
}
6+
}

0 commit comments

Comments
 (0)