mirror of
https://github.com/wassname/talk.git
synced 2026-08-19 12:40:16 +08:00
Prevent double execution of fetchMore
This commit is contained in:
@@ -53,6 +53,8 @@ function invalidateCursor(invalidated, state, props) {
|
||||
|
||||
class Stream extends React.Component {
|
||||
|
||||
isLoadingMoreMore = false;
|
||||
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = resetCursors(this.state, props);
|
||||
@@ -95,6 +97,18 @@ class Stream extends React.Component {
|
||||
}
|
||||
};
|
||||
|
||||
loadMoreComments = () => {
|
||||
if (!this.isLoadingMore) {
|
||||
this.isLoadingMore = true;
|
||||
this.props.loadMoreComments()
|
||||
.then(() => this.isLoadingMore = false)
|
||||
.catch((e) => {
|
||||
this.isLoadingMore = false;
|
||||
throw e;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// getVisibileComments returns a list containing comments
|
||||
// which were authored by current user or comes after the `idCursor`.
|
||||
getVisibleComments() {
|
||||
@@ -288,7 +302,7 @@ class Stream extends React.Component {
|
||||
<LoadMore
|
||||
topLevel={true}
|
||||
moreComments={asset.comments.hasNextPage}
|
||||
loadMore={this.props.loadMoreComments}
|
||||
loadMore={this.loadMoreComments}
|
||||
/>
|
||||
</div>}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user