diff --git a/client/coral-embed-stream/src/containers/Stream.js b/client/coral-embed-stream/src/containers/Stream.js index 593fa1eb0..360ee2ef9 100644 --- a/client/coral-embed-stream/src/containers/Stream.js +++ b/client/coral-embed-stream/src/containers/Stream.js @@ -14,6 +14,7 @@ import {setActiveReplyBox} from '../actions/stream'; import Stream from '../components/Stream'; import Comment from './Comment'; import {withFragments} from 'coral-framework/hocs'; +import {Spinner} from 'coral-ui'; import {getDefinitionName} from 'coral-framework/utils'; import { findCommentInEmbedQuery, @@ -141,6 +142,9 @@ class StreamContainer extends React.Component { } render() { + if (this.props.refetching) { + return ; + } return ({ auth: state.auth.toJS(), + refetching: state.embed.refetching, commentCountCache: state.stream.commentCountCache, activeReplyBox: state.stream.activeReplyBox, commentId: state.stream.commentId, diff --git a/client/coral-embed-stream/src/reducers/embed.js b/client/coral-embed-stream/src/reducers/embed.js index 0fd661543..8ccf4cbbc 100644 --- a/client/coral-embed-stream/src/reducers/embed.js +++ b/client/coral-embed-stream/src/reducers/embed.js @@ -3,6 +3,7 @@ import * as actions from '../constants/embed'; const initialState = { activeTab: 'stream', previousTab: '', + refetching: false, }; export default function stream(state = initialState, action) { @@ -13,6 +14,22 @@ export default function stream(state = initialState, action) { activeTab: action.tab, previousTab: state.activeTab, }; + case 'APOLLO_QUERY_INIT': + if (action.queryString.indexOf('query CoralEmbedStream_Embed(') >= 0) { + return { + ...state, + refetching: action.isRefetch, + }; + } + return state; + case 'APOLLO_QUERY_RESULT': + if (action.operationName === 'CoralEmbedStream_Embed') { + return { + ...state, + refetching: false, + }; + } + return state; default: return state; }