Fix retry to get posts race condition (#809)
This commit is contained in:
parent
fd0ca606bb
commit
01ab4af1e2
1 changed files with 10 additions and 6 deletions
|
|
@ -64,9 +64,7 @@ class ChannelPostList extends PureComponent {
|
|||
const {channel, posts, channelRefreshingFailed} = this.props;
|
||||
this.mounted = true;
|
||||
this.loadPosts(this.props.channel.id);
|
||||
if (posts.length || channel.total_msg_count === 0 || channelRefreshingFailed) {
|
||||
this.channelLoaded();
|
||||
}
|
||||
this.shouldMarkChannelAsLoaded(posts.length, channel.total_msg_count === 0, channelRefreshingFailed);
|
||||
}
|
||||
|
||||
componentWillReceiveProps(nextProps) {
|
||||
|
|
@ -78,9 +76,7 @@ class ChannelPostList extends PureComponent {
|
|||
this.setState({
|
||||
loaderOpacity: new Animated.Value(1)
|
||||
}, () => {
|
||||
if (nextPosts.length || nextChannel.total_msg_count === 0 || nextChannelRefreshingFailed) {
|
||||
this.channelLoaded();
|
||||
}
|
||||
this.shouldMarkChannelAsLoaded(nextPosts.length, nextChannel.total_msg_count === 0, nextChannelRefreshingFailed);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -95,6 +91,8 @@ class ChannelPostList extends PureComponent {
|
|||
this.toggleRetryMessage(false);
|
||||
}
|
||||
|
||||
this.shouldMarkChannelAsLoaded(nextPosts.length, nextChannel.total_msg_count === 0, nextChannelRefreshingFailed);
|
||||
|
||||
const showLoadMore = nextProps.posts.length >= nextProps.postVisibility;
|
||||
this.setState({
|
||||
showLoadMore
|
||||
|
|
@ -105,6 +103,12 @@ class ChannelPostList extends PureComponent {
|
|||
this.mounted = false;
|
||||
}
|
||||
|
||||
shouldMarkChannelAsLoaded = (postsCount, channelHasMessages, channelRefreshingFailed) => {
|
||||
if (postsCount || channelHasMessages || channelRefreshingFailed) {
|
||||
this.channelLoaded();
|
||||
}
|
||||
};
|
||||
|
||||
channelLoaded = () => {
|
||||
Animated.timing(this.state.loaderOpacity, {
|
||||
toValue: 0,
|
||||
|
|
|
|||
Loading…
Reference in a new issue