Merge pull request #657 from coralproject/better-refetch-detection

Better refetch detection
This commit is contained in:
David Erwin
2017-06-07 09:29:19 -04:00
committed by GitHub
2 changed files with 5 additions and 2 deletions
@@ -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);
@@ -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;