OneSignalDevelopers / ngosi

Share your slides with a QR code
https://ngosi.io
MIT License
9 stars 5 forks source link

Convert useSupabase hook to use the provider pattern #47

Closed iAmWillShepherd closed 2 years ago

iAmWillShepherd commented 2 years ago

Fixes #46.

Solution

I refactored the useSupbaseHook to be back by React context. I also pulled all the logic originally in the hook into a new functional component that will act as a provider to the app. I originally thought this would prevent the app flashing while it computes the auth state, but this is not the case, so I may need to work with someone who's stronger in React to address the issue (see #48).

Testing

These changes don't result in a change in behavior, but instead, reactors the useSupabase hook to implement the provider pattern. The test for these changes is effectively verifying that it works the same as before.

  1. Checkout dev branch
  2. Start supabase then start the app
  3. Log in to the app and create a preso
  4. Logout
  5. Checkout the PR branch, git checkout auth-provider
  6. Log in to the app and create a preso
  7. Note that there are no differences.

Resources

References

vercel[bot] commented 2 years ago

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/onesignaldevs/ngosi/Ej1CaLYhrDiLcNprkX18vEyzx6Hv
✅ Preview: https://ngosi-git-auth-provider-onesignaldevs.vercel.app