Commit 8d90279b authored by Jesús Espino's avatar Jesús Espino Committed by Joram Wilander

Throttling the postListScrollChange action (#1048)

parent 8cebfb70
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
import debounce from 'lodash/debounce';
import {
getChannel,
createDirectChannel,
......@@ -537,10 +539,17 @@ export async function redirectUserToDefaultTeam() {
}
}
export function postListScrollChange(forceScrollToBottom = false) {
export const postListScrollChange = debounce(() => {
AppDispatcher.handleViewAction({
type: EventTypes.POST_LIST_SCROLL_CHANGE,
value: false,
});
});
export function postListScrollChangeToBottom() {
AppDispatcher.handleViewAction({
type: EventTypes.POST_LIST_SCROLL_CHANGE,
value: forceScrollToBottom,
value: true,
});
}
......
......@@ -25,7 +25,7 @@ import {
} from 'mattermost-redux/actions/posts';
import {Posts} from 'mattermost-redux/constants';
import {emitUserPostedEvent, postListScrollChange} from 'actions/global_actions.jsx';
import {emitUserPostedEvent, postListScrollChangeToBottom} from 'actions/global_actions.jsx';
import {createPost, setEditingPost} from 'actions/post_actions.jsx';
import {selectPostFromRightHandSideSearchByPostId} from 'actions/views/rhs';
import {getPostDraft} from 'selectors/rhs';
......@@ -76,7 +76,7 @@ function onSubmitPost(post, fileInfos) {
return () => {
emitUserPostedEvent(post);
createPost(post, fileInfos);
postListScrollChange(true);
postListScrollChangeToBottom();
};
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment