fungible-systems / micro-stacks

Tiny libraries for building the next generation of Stacks apps.
https://micro-stacks.dev
MIT License
82 stars 15 forks source link

Onboarding API Improvements #8

Closed aviculturist closed 2 years ago

aviculturist commented 2 years ago

When a user arrives on the page, they might try to do something that requires signing into the wallet, even if they don't have the wallet installed. Or they might have the wallet installed but not connected to the site. Or the wallet might be installed and connected, in which case they can proceed.

At the moment, one needs to check isSignedIn, if the user isn't signed in, wrap handleSignIn in a try{}catch{}, but that doesn't actually return anything, so thereafter, one needs to check the session as returned from useAuth and if it's null, prompt the user to install the wallet.

I've got a mockup implementation that I believe covers all these onboarding scenarios but it would be cleaner if it were handled directly in the API

https://github.com/aviculturist/bird-count/blob/e54272466f3444d65cf3e0798df3568dc21eb008/src/components/bird-count-buttongroup.tsx#L64

aviculturist commented 2 years ago

My mockup implementation has one flaw. The first time you connect the wallet, it displays the onboarding popup even if you connect the account. If you sign out and then re-connect, it does not display it. Maybe session isn't being reset to null on sign out? Or maybe I'm misunderstanding the lifecycle here.