Skip to content
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

Merged
merged 2 commits into from
Apr 5, 2017

Conversation

mattwondra
Copy link
Member

@mattwondra mattwondra commented Mar 31, 2017

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:
screen shot 2017-03-31 at 2 52 20 pm

Connecting:
screen shot 2017-03-31 at 2 52 25 pm

Connected:
screen shot 2017-03-31 at 2 52 31 pm

New experience

Uninitialized:
screen shot 2017-03-31 at 2 45 42 pm

Connecting:
screen shot 2017-03-31 at 2 45 53 pm

Connected:
screen shot 2017-03-31 at 2 45 59 pm

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.

@matticbot
Copy link
Contributor

@matticbot matticbot added the [Size] XL Probably needs to be broken down into multiple smaller issues label Mar 31, 2017
@mattwondra mattwondra added Happychat [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. labels Mar 31, 2017
@mattwondra mattwondra requested a review from jordwest March 31, 2017 20:03
@mattwondra mattwondra force-pushed the update/happychat/refactor-helpers branch from e92a9cf to 3cca632 Compare April 3, 2017 21:00
@mattwondra mattwondra changed the base branch from master to fix/happychat/better-connect-redux-lifecycle April 3, 2017 21:01
Copy link
Contributor

@jordwest jordwest left a 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',
Copy link
Contributor

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.

Copy link
Member Author

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.

@mattwondra
Copy link
Member Author

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?

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.

@mattwondra mattwondra force-pushed the update/happychat/refactor-helpers branch from 3cca632 to 8de92f3 Compare April 5, 2017 15:54
@mattwondra mattwondra changed the base branch from fix/happychat/better-connect-redux-lifecycle to master April 5, 2017 15:56
@mattwondra mattwondra merged commit 5f0ef78 into master Apr 5, 2017
@matticbot matticbot removed the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Apr 5, 2017
@mattwondra mattwondra deleted the update/happychat/refactor-helpers branch April 5, 2017 16:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Happychat [Size] XL Probably needs to be broken down into multiple smaller issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants