Skip to content
This repository has been archived by the owner on Oct 1, 2019. It is now read-only.

Commit

Permalink
Settings: autoload more profile posts only after manual 'load more'
Browse files Browse the repository at this point in the history
  • Loading branch information
artkravchenko committed Mar 18, 2017
1 parent 2d1bfe9 commit c74a77a
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/pages/settings/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ class SettingsPage extends React.Component {
displayLoadMore: true
};

this.loadMoreAutomatically = false;
const client = new ApiClient(API_HOST);
this.triggers = new ActionsTrigger(client, props.dispatch);
}
Expand All @@ -99,6 +100,10 @@ class SettingsPage extends React.Component {
};

handleLoadMoreClick = async () => {
if (!this.loadMoreAutomatically) {
this.loadMoreAutomatically = true;
}

const res = await this.triggers.loadUserProfilePosts(
this.props.current_user.getIn(['user', 'username']),
this.props.profile_posts.size
Expand All @@ -110,6 +115,10 @@ class SettingsPage extends React.Component {
};

handleLoadMoreVisibilityChange = async (isVisible) => {
if (!this.loadMoreAutomatically) {
return;
}

if (isVisible && !this.props.loadProfilePostsInProgress) {
const res = await this.triggers.loadUserProfilePosts(
this.props.current_user.getIn(['user', 'username']), this.props.profile_posts.size
Expand Down

0 comments on commit c74a77a

Please sign in to comment.