diff --git a/client/coral-admin/src/routes/Moderation/components/ModerationQueue.js b/client/coral-admin/src/routes/Moderation/components/ModerationQueue.js index 490c2a985..d656c7a82 100644 --- a/client/coral-admin/src/routes/Moderation/components/ModerationQueue.js +++ b/client/coral-admin/src/routes/Moderation/components/ModerationQueue.js @@ -8,6 +8,7 @@ import LoadMore from './LoadMore'; import t from 'coral-framework/services/i18n'; class ModerationQueue extends React.Component { + isLoadingMore = false; static propTypes = { viewUserDetail: PropTypes.func.isRequired, @@ -22,7 +23,15 @@ class ModerationQueue extends React.Component { } loadMore = () => { - this.props.loadMore(this.props.activeTab); + if (!this.isLoadingMore) { + this.isLoadingMore = true; + this.props.loadMore(this.props.activeTab) + .then(() => this.isLoadingMore = false) + .catch((e) => { + this.isLoadingMore = false; + throw e; + }); + } } componentDidUpdate (prev) { diff --git a/client/coral-embed-stream/src/components/Comment.js b/client/coral-embed-stream/src/components/Comment.js index f14e4c991..53ac52edf 100644 --- a/client/coral-embed-stream/src/components/Comment.js +++ b/client/coral-embed-stream/src/components/Comment.js @@ -75,6 +75,8 @@ const ActionButton = ({children}) => { }; export default class Comment extends React.Component { + isLoadingReplies = false; + constructor(props) { super(props); @@ -210,14 +212,24 @@ export default class Comment extends React.Component { } loadNewReplies = () => { - const {replies, replyCount, id} = this.props.comment; - if (replyCount > replies.nodes.length) { - this.props.loadMore(id).then(() => { - this.setState(resetCursors(this.state, this.props)); - }); - return; + if (!this.isLoadingReplies) { + this.isLoadingReplies = true; + const {replies, replyCount, id} = this.props.comment; + if (replyCount > replies.nodes.length) { + this.props.loadMore(id) + .then(() => { + this.setState(resetCursors(this.state, this.props)); + this.isLoadingReplies = false; + }) + .catch((e) => { + this.isLoadingReplies = false; + throw e; + }); + return; + } + this.setState(resetCursors); + this.isLoadingReplies = false; } - this.setState(resetCursors); }; showReplyBox = () => { diff --git a/client/coral-embed-stream/src/components/LoadMore.js b/client/coral-embed-stream/src/components/LoadMore.js index ca2816d10..3d1ad4679 100644 --- a/client/coral-embed-stream/src/components/LoadMore.js +++ b/client/coral-embed-stream/src/components/LoadMore.js @@ -23,15 +23,17 @@ class LoadMore extends React.Component { } } + loadMore = () => { + this.initialState = false; + this.props.loadMore(); + } + render () { - const {topLevel, moreComments, loadMore, replyCount} = this.props; + const {topLevel, moreComments, replyCount} = this.props; return moreComments ?