devrnt / react-use-intercom

☎️ React Intercom integration without the hassle, powered by hooks.
https://devrnt.github.io/react-use-intercom/#/useIntercom
MIT License
337 stars 43 forks source link

Provide an `isBooted` value #679

Closed doulighan closed 3 months ago

doulighan commented 3 months ago

Is your feature request related to a problem? Please describe.

Maybe there's already a better way to do this that I'm missing. Suggestions welcome!

A possible flow might look like: 1) Unauthenticated user loads the page. autoBoot begins Intercom in "Visitor" mode, to cover the login page or cover the user if session auth fails. 2) The user authenticates, and we call update() to put Intercom into "User" mode. 3) The user signs out. We call shutdown() to clear storage. 4) The user signs back in without refreshing the page. Now, our typical call to update() will fail.

Describe the solution you'd like

An isBooted value would make it easy to conditionally call boot() or update().

Describe alternatives you've considered

a) Manually reboot intercom in "Visitor" mode immediately after calling shudown, before the redirect to /login.

b) Track isBooted ourselves in a global variable

c) Don't use autoBoot, manage Visitors and Users separately

doulighan commented 3 months ago

Edit: It appears this was already discussed and declined here https://github.com/devrnt/react-use-intercom/issues/149#issuecomment-738207869, I'll close this one.

And additionally, I've learned now that boot can be called multiple times, which fixes my specific issue. See https://github.com/devrnt/react-use-intercom/issues/555