Skip to content
This repository has been archived by the owner on Mar 13, 2024. It is now read-only.

Revert virtualised and auto load of posts #2622

Merged
merged 9 commits into from
Apr 8, 2019
Prev Previous commit
Next Next commit
Revert "MM-14810 Fix for infinite loop caused by loading channels wit…
…h content less than screen height (#2572)"

This reverts commit b11b42c.
  • Loading branch information
sudheerDev committed Apr 5, 2019
commit ba6d79a18bf17ac4c4a9da36893a31ab44cfdf95
17 changes: 8 additions & 9 deletions components/post_view/post_list.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,14 @@ export default class PostList extends React.PureComponent {
constructor(props) {
super(props);

this.loadingMorePosts = false;
this.loadingPosts = false;
this.extraPagesLoaded = 0;

const channelIntroMessage = PostListRowListIds.CHANNEL_INTRO_MESSAGE;
const isMobile = Utils.isMobile();
this.state = {
atEnd: false,
loadingFirstSetOfPosts: !props.posts || props.channelLoading,
postsLoading: !props.posts || props.channelLoading,
isScrolling: false,
lastViewed: props.lastViewedAt,
autoRetryEnable: true,
Expand Down Expand Up @@ -260,7 +260,7 @@ export default class PostList extends React.PureComponent {
if (this.mounted) {
const atEnd = Boolean(posts && posts.order.length < POSTS_PER_PAGE);
const newState = {
loadingFirstSetOfPosts: false,
postsLoading: false,
atEnd,
};

Expand All @@ -269,7 +269,6 @@ export default class PostList extends React.PureComponent {
}

loadMorePosts = async () => {
this.loadingMorePosts = true;
const {moreToLoad, error} = await this.props.actions.increasePostVisibility(this.props.channel.id, this.props.focusedPostId);
if (error) {
if (this.autoRetriesCount < MAX_NUMBER_OF_AUTO_RETRIES) {
Expand All @@ -279,7 +278,7 @@ export default class PostList extends React.PureComponent {
this.setState({autoRetryEnable: false});
}
} else {
this.loadingMorePosts = false;
this.loadingPosts = false;
if (this.mounted && this.props.posts) {
const atEnd = !moreToLoad && this.props.posts.length < this.props.postVisibility;
const newState = {
Expand Down Expand Up @@ -328,11 +327,11 @@ export default class PostList extends React.PureComponent {
}

onScroll = ({scrollDirection, scrollOffset, scrollUpdateWasRequested}) => {
const isNotLoadingPosts = !this.state.loadingFirstSetOfPosts && !this.loadingMorePosts;
const isNotLoadingPosts = !this.state.postsLoading && !this.loadingPosts;
const didUserScrollBackwards = scrollDirection === 'backward' && !scrollUpdateWasRequested;
const isOffsetWithInRange = scrollOffset < HEIGHT_TRIGGER_FOR_MORE_POSTS;
if (isNotLoadingPosts && didUserScrollBackwards && isOffsetWithInRange && !this.state.atEnd) {
this.loadingMorePosts = true;
this.loadingPosts = true;
this.loadMorePosts();
}

Expand Down Expand Up @@ -431,7 +430,7 @@ export default class PostList extends React.PureComponent {
return;
}

if (this.state.loadingFirstSetOfPosts || this.loadingMorePosts) {
if (this.state.postsLoading || this.loadingPosts) {
// Should already be loading posts
return;
}
Expand All @@ -455,7 +454,7 @@ export default class PostList extends React.PureComponent {
render() {
const channel = this.props.channel;

if (this.state.loadingFirstSetOfPosts || channel == null) {
if (this.state.postsLoading || channel == null) {
return (
<div id='post-list'>
<LoadingScreen
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"react-select": "2.4.1",
"react-transition-group": "2.6.0",
"react-virtualized-auto-sizer": "^1.0.2",
"react-window": "github:mattermost/react-window#22cab3a8a0f4e3793ba778a990f1c0723b4c8129",
"react-window": "github:mattermost/react-window#cb3b6531136ea040984210d7b04d890c8c6031e2",
"rebound": "0.1.0",
"redux": "4.0.1",
"redux-batched-actions": "0.4.1",
Expand Down