-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Happychat: Refactor out helper.js for clearer loading states #12706
Conversation
e92a9cf
to
3cca632
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good and chat works, but the disconnection events aren't handled in the middleware so the disconnected
notice isn't shown. Is that intended to come in a separate PR?
@@ -63,7 +72,10 @@ export const Composer = React.createClass( { | |||
} | |||
} ); | |||
|
|||
const mapState = ( { happychat: { message } } ) => ( { message } ); | |||
const mapState = state => ( { | |||
disabled: getHappychatConnectionStatus( state ) !== 'connected', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm wondering if we should extract this into a selector, for example canUserSendMessage
?
We might also want to check the chat status as well, for example if the chat is connected but pending
or missed
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great suggestion, I'll add that in.
Yep, that's done in PR #12754. Both of these PRs are based on your work in #12219, but I just split them up so that the review of the helper.js refactor and the disconnect messaging were both a little easier. |
3cca632
to
8de92f3
Compare
This PR lays foundation for improving Happychat connection statuses to handle lost connections and reconnects (#12183), by refactoring out the
helper.js
which primarily existed to show interface elements in various states. Most of this work comes from @jordwest's PR #12219, which I'm splitting up into two parts — the next PR will introduce new connection statuses for various connectivity issues.The screenshots below compare the current Happychat load experience with the new one. This shows on the
/me/chat
page where HC is visible from the beginning, but in practice most users will interact through the sidebar HC. That sidebar usually pre-connects before it's visible, so most of the time users won't see these loading states. But simplifying in this way will help with the following PR, where we'll give users more feedback about connection issues.Screenshot comparison
Current experience
Uninitialized:
Connecting:
Connected:
New experience
Uninitialized:
Connecting:
Connected:
To test
Make sure that normal paths to Happychat communication work as expected. You can use Redux Dev Tools to scrub through the various loading states.