From 20b4c4e2d0430855d780ce20dc21832c62ec9f93 Mon Sep 17 00:00:00 2001 From: Chi Vinh Le Date: Thu, 27 Apr 2017 17:30:43 +0700 Subject: [PATCH] Only query once during initial render --- client/coral-embed-stream/src/containers/Stream.js | 5 ++++- client/coral-embed-stream/src/reducers/embed.js | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/client/coral-embed-stream/src/containers/Stream.js b/client/coral-embed-stream/src/containers/Stream.js index 4df7fc960..4415f5f94 100644 --- a/client/coral-embed-stream/src/containers/Stream.js +++ b/client/coral-embed-stream/src/containers/Stream.js @@ -118,7 +118,9 @@ class StreamContainer extends React.Component { }; componentDidMount() { - this.props.data.refetch(); + if (this.props.previousTab) { + this.props.data.refetch(); + } this.countPoll = setInterval(() => { const {asset} = this.props.root; this.getCounts({ @@ -236,6 +238,7 @@ const mapStateToProps = state => ({ assetId: state.stream.assetId, assetUrl: state.stream.assetUrl, activeTab: state.embed.activeTab, + previousTab: state.embed.previousTab, }); const mapDispatchToProps = dispatch => diff --git a/client/coral-embed-stream/src/reducers/embed.js b/client/coral-embed-stream/src/reducers/embed.js index e7fe5a533..0fd661543 100644 --- a/client/coral-embed-stream/src/reducers/embed.js +++ b/client/coral-embed-stream/src/reducers/embed.js @@ -2,6 +2,7 @@ import * as actions from '../constants/embed'; const initialState = { activeTab: 'stream', + previousTab: '', }; export default function stream(state = initialState, action) { @@ -10,6 +11,7 @@ export default function stream(state = initialState, action) { return { ...state, activeTab: action.tab, + previousTab: state.activeTab, }; default: return state;