From ceb99cf20588bdc450d1b2822d219eb32f690384 Mon Sep 17 00:00:00 2001 From: Chi Vinh Le Date: Wed, 7 Jun 2017 17:45:33 +0700 Subject: [PATCH] Better refetch detection --- client/coral-embed-stream/src/components/Comment.js | 1 + client/coral-embed-stream/src/reducers/embed.js | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/client/coral-embed-stream/src/components/Comment.js b/client/coral-embed-stream/src/components/Comment.js index 71117563d..228dd4c41 100644 --- a/client/coral-embed-stream/src/components/Comment.js +++ b/client/coral-embed-stream/src/components/Comment.js @@ -297,6 +297,7 @@ class Comment extends React.Component { } = this.props; const view = this.getVisibileReplies(); + const hasMoreComments = comment.replies && (comment.replies.hasNextPage || comment.replies.nodes.length > view.length); const replyCount = this.hasIgnoredReplies() ? '' : comment.replyCount; const flagSummary = getActionSummary('FlagActionSummary', comment); diff --git a/client/coral-embed-stream/src/reducers/embed.js b/client/coral-embed-stream/src/reducers/embed.js index 8ccf4cbbc..06073c54e 100644 --- a/client/coral-embed-stream/src/reducers/embed.js +++ b/client/coral-embed-stream/src/reducers/embed.js @@ -4,6 +4,7 @@ const initialState = { activeTab: 'stream', previousTab: '', refetching: false, + refetchRequestId: 0, }; export default function stream(state = initialState, action) { @@ -18,7 +19,8 @@ export default function stream(state = initialState, action) { if (action.queryString.indexOf('query CoralEmbedStream_Embed(') >= 0) { return { ...state, - refetching: action.isRefetch, + refetching: action.isRefetch ? true : state.refetching, + refetchRequestId: action.isRefetch ? action.requestId : state.refetchRequestId, }; } return state; @@ -26,7 +28,7 @@ export default function stream(state = initialState, action) { if (action.operationName === 'CoralEmbedStream_Embed') { return { ...state, - refetching: false, + refetching: action.requestId === state.refetchRequestId ? false : state.refetching, }; } return state;