digidem / digidem/comapeo-core-react
Make it easier to use write hooks that involve passing references from preceding write operations
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 1
- Forks
- 1
- Avg merge
- 5m
- Merged PRs (30d)
- 2
Description
Extracted from https://github.com/digidem/comapeo-core-react/issues/20
The most notable example of this is when creating/updating observations that have attachments. Right now, the end-user has to work with the relevant write hook to create the attachment(s) prior to creating the observation e.g.
const createBlob = useCreateBlob(...)
const createObservation = useCreateDoc({ docType: 'observation', ... })
// Example of a single attachment
function onPress() {
createBlob.mutate(..., {
onSuccess: (blob) => {
// Create observation that references blob after its creation
createObservation.mutate({ value: { attachments: [{ ...blob, driveDiscoveryId: blob.driveId }] }, ...})
}
})
}
// Example of multiple attachments
function onPress() {
Promise.all([
createBlob.mutateAsync(...),
createBlob.mutateAsync(...),
]).then(attachments => {
// Create observation that has multiple attachments
createObservation.mutate({ value: { attachments: blobs.map((b) => ({ ...b, driveDiscoveryId: blob.driveId })), ... } })
})
}
The idea would be to have something similar to what the original issue outlined such that the end-user code could look more like this:
createObservation.mutate({ value: ..., attachmentsToAdd: [...] })
As mentioned in https://github.com/digidem/comapeo-core-react/pull/26, I didn't figure out a satisfactory way of implementing this and decided to leave that as a follow-up, since it's mostly for end-usage convenience.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No files or tests are identified in the issue. Start by reviewing the existing write hooks, the extracted issue, and pull request #26 to understand the rejected approach; done should let callers pass attachments to the observation mutation without manually chaining blob creation operations.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react, typescript
- Domain
- frontend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100