Conversation
ErikSin
left a comment
There was a problem hiding this comment.
There are a few event emitters/listeners needed.
- The ui is designed to constantly be listening in the background and notify the user when a map has been shared. So there needs to be some listener function that invalidates the
useManyMapSharesfunction when a map get shared that lives at the top of the app - Similar to invites, the person receiving the map needs to also listen in the background for when the person sending the map has cancelled sending the map. This has to be listener because it can happen at any time during the process.
- As mentioned in the comments, if we want to show progress of the map being downloaded, the map sharing function needs to be an event emitter. As it is now, there is no way to show the progress in the ui as it an async function that will just return one object when resolved at the end.
cimigree
left a comment
There was a problem hiding this comment.
I agree with what Erik said. Thanks for the thorough review, Erik. I added a few things that I noticed as well.
|
Hi, @gmaclennan
|
I can update this branch to export those hooks!
Yes this is branch is based off of main, which includes the changes from #141 . You no longer need to use that hook as it's done automatically when setting up the api client provider.
Can fix this for you.
|
|
I will try and re-visit this API tomorrow now that I've got further into the implementation. We will actually need two similar APIs I think for managing the map shares from the sender side and from the receiver side. They are subtly different and I think this current API design maybe conflates the two. It could be possible to make this current API design work for both I guess - I'll look into this. |
|
@cimigree & @ErikSin : So after implementing this, I realize there is a slight confusion with this API with the distinction between sent map shares and received map shares, which I imagine you have encountered when you are implementing this? For the API we have a couple of options:
Which do you think would be preferable to work with? I am thinking (2) is better because you there would never be a use-case for reading both sent and received map shares at the same time, and it would complicate the effects (e.g. showing the share offer screen) when the value updates. |
* main: chore: update deps and actions (#148)
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
|
I've updated the PR description with the completed API. This is now ready for review. |
|
@achou11 there are a couple more hooks tests still pending (download progress related) and I think maybe I can delete the unit tests for the stores, which are now testing an implementation detail, once I verify that the hooks tests are covering the same things (I created the stores tests first so I could fix bugs before writing the hooks). I added a helper |
|
All alerts resolved. Learn more about Socket for GitHub. This PR previously contained dependency changes with security issues that have been resolved, removed, or ignored. |
|
The latest changes may/should address the react native Request compatibility issues by removing |
So sorry but it doesn't seem to be working or I need more guidance on how to use. |
Map Sharing Hooks
Adds React hooks for sharing maps between devices. The API separates receiver and sender functionality.
Receiver Hooks
useManyReceivedMapShares()- List all received map shares. Updates when shares arrive or status changes (but not during download progress updates).useSingleReceivedMapShare({ shareId })- Get a specific received share with real-time updates including download progress.useDownloadReceivedMapShare()- Accept and start downloading a share. Resolves when download starts, not when complete.useDeclineReceivedMapShare()- Decline a pending share. Notifies the sender.useAbortReceivedMapShareDownload()- Cancel an in-progress download.Sender Hooks
useSendMapShare({ projectId })- Send a map to another device. Resolves immediately with the share object (doesn't wait for recipient response).useSingleSentMapShare({ shareId })- Track a sent share's status in real-time (pending, downloading, declined, canceled).useCancelSentMapShare()- Cancel a sent share before the recipient completes the download.Example Usage