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
Revert infinite scroll from release 5.8v (#2303)
* Revert infinite scroll changes

* Fix an error with ScrollToBottomArrows

  * Fix the error of onClick with scrollToBottomArrow prop

* Remove unused variables
  • Loading branch information
sudheerDev committed Apr 5, 2019
commit bc1753c641e0c9b3187a24ae6f9392b84d2ec0be
35 changes: 15 additions & 20 deletions actions/post_actions.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,18 @@ export function increasePostVisibility(channelId, focusedPostId) {
return true;
}

dispatch({
type: ActionTypes.LOADING_POSTS,
data: true,
channelId,
});
dispatch(batchActions([
{
type: ActionTypes.LOADING_POSTS,
data: true,
channelId,
},
{
type: ActionTypes.INCREASE_POST_VISIBILITY,
data: channelId,
amount: POST_INCREASE_AMOUNT,
},
]));

const page = Math.floor(currentPostVisibility / POST_INCREASE_AMOUNT);

Expand All @@ -161,25 +168,13 @@ export function increasePostVisibility(channelId, focusedPostId) {
}
const posts = result.data;

const actions = [{
dispatch({
type: ActionTypes.LOADING_POSTS,
data: false,
channelId,
}];

if (posts) {
actions.push({
type: ActionTypes.INCREASE_POST_VISIBILITY,
data: channelId,
amount: posts.order.length,
});
}
});

dispatch(batchActions(actions));
return {
moreToLoad: posts ? posts.order.length >= POST_INCREASE_AMOUNT : false,
error: result.error,
};
return posts ? posts.order.length >= POST_INCREASE_AMOUNT : false;
};
}

Expand Down
27 changes: 15 additions & 12 deletions actions/post_actions.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,40 +228,43 @@ describe('Actions.Posts', () => {

await testStore.dispatch(Actions.increasePostVisibility('current_channel_id'));
expect(testStore.getActions()).toEqual([
{channelId: 'current_channel_id', data: true, type: 'LOADING_POSTS'},
{args: ['current_channel_id', 2, 30], type: 'MOCK_GET_POSTS'},
{
meta: {batch: true},
payload: [
{channelId: 'current_channel_id', data: false, type: 'LOADING_POSTS'},
{channelId: 'current_channel_id', data: true, type: 'LOADING_POSTS'},
{amount: 30, data: 'current_channel_id', type: 'INCREASE_POST_VISIBILITY'},
],
type: 'BATCHING_REDUCER.BATCH',
},
{args: ['current_channel_id', 2, 30], type: 'MOCK_GET_POSTS'},
{channelId: 'current_channel_id', data: false, type: 'LOADING_POSTS'},
]);

await testStore.dispatch(Actions.increasePostVisibility('current_channel_id', 'latest_post_id'));
expect(testStore.getActions()).toEqual([
{channelId: 'current_channel_id', data: true, type: 'LOADING_POSTS'},
{args: ['current_channel_id', 2, 30], type: 'MOCK_GET_POSTS'},
{
meta: {batch: true},
payload: [
{channelId: 'current_channel_id', data: false, type: 'LOADING_POSTS'},
{channelId: 'current_channel_id', data: true, type: 'LOADING_POSTS'},
{amount: 30, data: 'current_channel_id', type: 'INCREASE_POST_VISIBILITY'},
],
type: 'BATCHING_REDUCER.BATCH',
},
{channelId: 'current_channel_id', data: true, type: 'LOADING_POSTS'},
{
args: ['current_channel_id', 'latest_post_id', 2, 30],
type: 'MOCK_GET_POSTS_BEFORE',
},
{args: ['current_channel_id', 2, 30], type: 'MOCK_GET_POSTS'},
{channelId: 'current_channel_id', data: false, type: 'LOADING_POSTS'},
{
meta: {batch: true},
payload: [
{channelId: 'current_channel_id', data: false, type: 'LOADING_POSTS'},
{channelId: 'current_channel_id', data: true, type: 'LOADING_POSTS'},
{amount: 30, data: 'current_channel_id', type: 'INCREASE_POST_VISIBILITY'},
],
type: 'BATCHING_REDUCER.BATCH',
},
{
args: ['current_channel_id', 'latest_post_id', 2, 30],
type: 'MOCK_GET_POSTS_BEFORE',
},
{channelId: 'current_channel_id', data: false, type: 'LOADING_POSTS'},
]);
});

Expand Down
Loading