From 92205a2c6f85c29519053cd07d398d9fec9fb5e9 Mon Sep 17 00:00:00 2001 From: Chi Vinh Le Date: Thu, 13 Apr 2017 01:17:46 +0700 Subject: [PATCH 1/2] Fix load more buttons --- client/coral-embed-stream/src/Embed.js | 12 +++++++++--- client/coral-embed-stream/src/NewCount.js | 4 ++-- .../graphql/queries/streamQuery.graphql | 3 +++ graph/resolvers/asset.js | 7 +++++++ graph/typeDefs.graphql | 3 +++ 5 files changed, 24 insertions(+), 5 deletions(-) diff --git a/client/coral-embed-stream/src/Embed.js b/client/coral-embed-stream/src/Embed.js index d9b5c8310..a16852c00 100644 --- a/client/coral-embed-stream/src/Embed.js +++ b/client/coral-embed-stream/src/Embed.js @@ -79,10 +79,12 @@ class Embed extends Component { if(!isEqual(nextProps.data.asset, this.props.data.asset)) { loadAsset(nextProps.data.asset); - const {getCounts, updateCountCache} = this.props; + const {getCounts, updateCountCache, asset: {countCache}} = this.props; const {asset} = nextProps.data; - updateCountCache(asset.id, asset.commentCount); + if (!countCache) { + updateCountCache(asset.id, asset.commentCount); + } this.setState({ countPoll: setInterval(() => { @@ -127,6 +129,10 @@ class Embed extends Component { const banned = user && user.status === 'BANNED'; + const hasOlderComments = + asset && asset.lastComment && + asset.lastComment.id !== asset.comments[asset.comments.length - 1].id; + const expandForLogin = showSignInDialog ? { minHeight: document.body.scrollHeight + 200 } : {}; @@ -259,7 +265,7 @@ class Embed extends Component { topLevel={true} assetId={asset.id} comments={asset.comments} - moreComments={countCache[asset.id] > asset.comments.length} + moreComments={hasOlderComments} loadMore={this.props.loadMore} /> } diff --git a/client/coral-embed-stream/src/NewCount.js b/client/coral-embed-stream/src/NewCount.js index 2368c1ab8..8d7333aab 100644 --- a/client/coral-embed-stream/src/NewCount.js +++ b/client/coral-embed-stream/src/NewCount.js @@ -17,10 +17,10 @@ const onLoadMoreClick = ({loadMore, commentCount, firstCommentDate, assetId, upd const NewCount = (props) => { const newComments = props.commentCount - props.countCache; - return
+ return
{ props.countCache && newComments > 0 ? -