message: Fixes infinite scrolling issues on Follow-ing/ers
diff: @@ -2,9 +2,10 @@ import React, { Component } from 'react';
  import PropTypes from 'prop-types';
  import { Query } from 'react-apollo';
  -import BlocksLoadingIndicator from 'react/components/UI/BlocksLoadingIndicator';
  import Grid from 'react/components/UI/Grid';
  import Cell from 'react/components/Cell';
  +import ErrorAlert from 'react/components/UI/ErrorAlert';
  +import BlocksLoadingIndicator from 'react/components/UI/BlocksLoadingIndicator';
  import profileFollowingQuery from 'react/components/ProfileFollows/queries/profileFollowing';
  import profileFollowersQuery from 'react/components/ProfileFollows/queries/profileFollowers';
  @@ -27,10 +28,7 @@ export default class ProfileFollows extends Component {
  fetchMore({
  variables: { page: page + 1, per },
  - updateQuery: (prevResult, { fetchMoreResult }) => {
  - if (!fetchMoreResult) return prevResult;
  -
  - return {
  + updateQuery: (prevResult, { fetchMoreResult }) => ({
  ...prevResult,
  identity: {
  ...prevResult.identity,
  @@ -42,12 +40,14 @@ export default class ProfileFollows extends Component {
  ],
  },
  },
  - };
  - },
  - }).then((res) => {
  + }),
  + }).then(({ errors, data }) => {
  + const { identity: { identifiable: { [type]: { length } } } } = data;
  + const hasMore = !errors && length > 0 && length >= per;
  +
  this.setState({
  page: page + 1,
  - hasMore: !res.errors && res.data.identity.identifiable[type].length > 0,
  + hasMore,
  });
  });
  }
  @@ -67,18 +67,29 @@ export default class ProfileFollows extends Component {
  {({
  loading, error, data, fetchMore,
  }) => {
  - if (loading) return <BlocksLoadingIndicator />;
  - if (error) return error.message;
  + if (error) {
  + return (
  + <ErrorAlert>
  + {error.message}
  + </ErrorAlert>
  + );
  + }
  +
  + if (!data.identity) {
  + return <BlocksLoadingIndicator />;
  + }
  const { identity: { identifiable: { [type]: collection } } } = data;
  return (
  + <div>
  + {!loading && collection.length > 0 &&
  <Grid
  pageStart={1}
  threshold={500}
  initialLoad={false}
  loader={<BlocksLoadingIndicator key="loading" />}
  - hasMore={hasMore}
  + hasMore={collection.length >= per && hasMore}
  loadMore={this.loadMore(fetchMore)}
  >
  {collection.map(cell => ({
  @@ -87,6 +98,8 @@ export default class ProfileFollows extends Component {
  Group: <Cell.Identifiable key={`${cell.__typename}_${cell.id}`} identifiable={cell} />,
  }[cell.__typename]))}
  </Grid>
  + }
  + </div>
  );
  }}
  </Query>
  