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
Next Next commit
Revert "MM-14810 Fix for channel header loading in center channel (#2596
)"

This reverts commit 6bc18af.
  • Loading branch information
sudheerDev committed Apr 5, 2019
commit f42cabf1f24e4e132a5e5441d708a1f2d6c9d074
2 changes: 1 addition & 1 deletion components/post_view/post_list.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ export default class PostList extends React.PureComponent {
} else {
this.loadingMorePosts = false;
if (this.mounted && this.props.posts) {
const atEnd = !moreToLoad;
const atEnd = !moreToLoad && this.props.posts.length < this.props.postVisibility;
const newState = {
atEnd,
autoRetryEnable: true,
Expand Down
52 changes: 13 additions & 39 deletions components/post_view/post_list.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,9 @@
import React from 'react';
import {shallow} from 'enzyme';

import {mountWithIntl} from 'tests/helpers/intl-test-helper.jsx';

import PostList from 'components/post_view/post_list.jsx';
import {PostListRowListIds} from 'utils/constants.jsx';

const returnDummyPostsAndIds = () => {
const postsArray = [];
const Ids = [];
const createAtValue = 12346;
for (var i = 1; i <= 30; i++) {
const postCreatedAt = createAtValue + i;
postsArray.push({
id: `${postCreatedAt}`,
message: 'test',
create_at: postCreatedAt,
});
Ids.push(`${postCreatedAt}`);
}

return {
postsArray,
Ids,
};
};

describe('components/post_view/post_list', () => {
const posts = [{
id: 'postId',
Expand Down Expand Up @@ -62,7 +40,19 @@ describe('components/post_view/post_list', () => {
};

test('should return index of loader when all are unread messages in the view and call increasePostVisibility action', () => {
const {Ids, postsArray} = returnDummyPostsAndIds();
const postsArray = [];
const Ids = [];
const createAtValue = 12346;
for (var i = 1; i <= 30; i++) {
const postCreatedAt = createAtValue + i;
postsArray.push({
id: `${postCreatedAt}`,
message: 'test',
create_at: postCreatedAt,
});
Ids.push(`${postCreatedAt}`);
}

const postListIds = [...Ids, PostListRowListIds.START_OF_NEW_MESSAGES];
const props = {
...baseProps,
Expand All @@ -75,20 +65,4 @@ describe('components/post_view/post_list', () => {
expect(initScrollToIndex).toEqual({index: 31, position: 'start'}); //Loader will be at pos 31
expect(actions.increasePostVisibility).toHaveBeenCalledTimes(1);
});

test('should set the state of atEnd to true when increasePostVisibility returns moreToLoad false', async () => {
const increasePostVisibilityMock = jest.fn().mockResolvedValue({moreToLoad: false});
const props = {
...baseProps,
actions: {
...baseProps.actions,
increasePostVisibility: increasePostVisibilityMock,
},
};
const wrapper = mountWithIntl(<PostList {...props}/>);
await wrapper.instance().loadMorePosts();
expect(increasePostVisibilityMock).toHaveBeenCalledTimes(1);
wrapper.update();
expect(wrapper.state('atEnd')).toEqual(true);
});
});