diff --git a/app/actions/views/channel.js b/app/actions/views/channel.js index cf5e4a555..3943c3780 100644 --- a/app/actions/views/channel.js +++ b/app/actions/views/channel.js @@ -468,7 +468,7 @@ export function increasePostVisibility(channelId, focusedPostId) { const currentPostVisibility = postVisibility[channelId] || 0; if (loadingPosts[channelId]) { - return; + return false; } // Check if we already have the posts that we want to show @@ -484,7 +484,7 @@ export function increasePostVisibility(channelId, focusedPostId) { setLoadMorePostsVisible(true), ])); - return; + return true; } } @@ -520,6 +520,8 @@ export function increasePostVisibility(channelId, focusedPostId) { } dispatch(batchActions(actions)); + + return Boolean(posts); }; } diff --git a/app/components/post_list/post_list.js b/app/components/post_list/post_list.js index d4b056da5..d5d3bd502 100644 --- a/app/components/post_list/post_list.js +++ b/app/components/post_list/post_list.js @@ -43,6 +43,7 @@ export default class PostList extends PureComponent { lastViewedAt: PropTypes.number, // Used by container // eslint-disable-line no-unused-prop-types measureCellLayout: PropTypes.bool, navigator: PropTypes.object, + onContentSizeChange: PropTypes.func, onEndReached: PropTypes.func, onPermalinkPress: PropTypes.func, onPostPress: PropTypes.func, @@ -345,6 +346,7 @@ export default class PostList extends PureComponent { return ( { + this.contentHeight = contentHeight; + }; + loadMorePosts = debounce(() => { if (this.props.loadMorePostsVisible) { const {actions, channelId} = this.props; - actions.increasePostVisibility(channelId); + actions.increasePostVisibility(channelId).then((hasMore) => { + if (hasMore && this.contentHeight < this.props.deviceHeight) { + // We still have less than 1 screen of posts loaded with more to get, so load more + this.loadMorePosts(); + } + }); } }, 100); @@ -198,6 +210,7 @@ export default class ChannelPostList extends PureComponent {