From c756b22302c2d4e0792c9a5c006e050edaed7e6b Mon Sep 17 00:00:00 2001 From: David Jay Date: Mon, 13 Feb 2017 15:15:27 -0500 Subject: [PATCH] Switching Load More to stateless component. --- client/coral-embed-stream/src/Embed.js | 26 ++++++--------------- client/coral-embed-stream/src/LoadMore.js | 4 ++-- client/coral-embed-stream/style/default.css | 1 + client/coral-framework/translations.json | 2 ++ 4 files changed, 12 insertions(+), 21 deletions(-) diff --git a/client/coral-embed-stream/src/Embed.js b/client/coral-embed-stream/src/Embed.js index 3acbc30d9..116c8d34e 100644 --- a/client/coral-embed-stream/src/Embed.js +++ b/client/coral-embed-stream/src/Embed.js @@ -3,7 +3,7 @@ import {compose} from 'react-apollo'; import {connect} from 'react-redux'; import isEqual from 'lodash/isEqual'; -import {TabBar, Tab, TabContent, Spinner, Button} from 'coral-ui'; +import {TabBar, Tab, TabContent, Spinner} from 'coral-ui'; const {logout, showSignInDialog, requestConfirmEmail} = authActions; const {addNotification, clearNotification} = notificationActions; @@ -25,6 +25,7 @@ import ChangeDisplayNameContainer from '../../coral-sign-in/containers/ChangeDis import SettingsContainer from 'coral-settings/containers/SettingsContainer'; import RestrictedContent from 'coral-framework/components/RestrictedContent'; import ConfigureStreamContainer from 'coral-configure/containers/ConfigureStreamContainer'; +import LoadMore from './LoadMore'; class Embed extends Component { @@ -77,20 +78,6 @@ class Embed extends Component { } } - loadMoreComments = () => { - - if (!this.props.asset.comments.length) { - return; - } - - this.props.loadMore({ - limit: 10, - cursor: this.props.asset.comments[this.props.asset.comments.length - 1].created_at, - asset_id: this.props.asset.id, - sort: 'REVERSE_CHRONOLOGICAL' - }); - } - render () { const {activeTab} = this.state; const {closedAt} = this.props.asset; @@ -170,10 +157,11 @@ class Embed extends Component { clearNotification={this.props.clearNotification} notification={{text: null}} /> - + asset.comments.length} + loadMore={this.props.loadMore}/> { @@ -18,7 +18,7 @@ const loadMoreComments = (id, comments, loadMore) => { }); }; -const LoadMore = ({id, comments, loadMore}) => comments.length > 5 ? +const LoadMore = ({id, comments, loadMore, moreComments}) => moreComments ?