Skip to content

Commit

Permalink
Check initialIndex in callback (#3065)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattermost-build authored and migbot committed Aug 1, 2019
1 parent f71d956 commit 361528d
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions app/components/post_list/post_list.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,10 +201,8 @@ export default class PostList extends PureComponent {
};

handleScrollToIndexFailed = () => {
requestAnimationFrame(() => {
this.hasDoneInitialScroll = false;
this.scrollToInitialIndexIfNeeded(1, 1);
});
this.hasDoneInitialScroll = false;
this.scrollToInitialIndexIfNeeded(1, 1);
};

handleSetScrollToBottom = () => {
Expand Down Expand Up @@ -291,11 +289,10 @@ export default class PostList extends PureComponent {
if (
width > 0 &&
height > 0 &&
this.props.initialIndex > 0 &&
!this.hasDoneInitialScroll
) {
requestAnimationFrame(() => {
if (this.flatListRef?.current) {
if (this.props.initialIndex > 0 && this.flatListRef?.current) {
this.flatListRef.current.scrollToIndex({
animated: false,
index: this.props.initialIndex,
Expand Down

0 comments on commit 361528d

Please sign in to comment.