From 00c2305ff73d38c7dc28c9fbc02754cb2937458d Mon Sep 17 00:00:00 2001 From: David Jay Date: Tue, 14 Feb 2017 18:29:59 -0500 Subject: [PATCH 1/3] Adding view more button to replies. --- client/coral-embed-stream/src/Comment.js | 13 +++++++++ client/coral-embed-stream/src/Embed.js | 1 + client/coral-embed-stream/src/LoadMore.js | 15 ++++++---- client/coral-embed-stream/src/Stream.js | 2 ++ client/coral-embed-stream/style/default.css | 10 +++++++ .../coral-framework/graphql/queries/index.js | 28 +++++++++++++++---- .../graphql/queries/loadMore.graphql | 1 + .../graphql/queries/streamQuery.graphql | 1 + 8 files changed, 60 insertions(+), 11 deletions(-) diff --git a/client/coral-embed-stream/src/Comment.js b/client/coral-embed-stream/src/Comment.js index 3bf787a9c..034c44f6a 100644 --- a/client/coral-embed-stream/src/Comment.js +++ b/client/coral-embed-stream/src/Comment.js @@ -17,6 +17,7 @@ import PubDate from 'coral-plugin-pubdate/PubDate'; import {ReplyBox, ReplyButton} from 'coral-plugin-replies'; import FlagComment from 'coral-plugin-flags/FlagComment'; import LikeButton from 'coral-plugin-likes/LikeButton'; +import LoadMore from 'coral-embed-stream/src/LoadMore'; import styles from './Comment.css'; @@ -89,6 +90,7 @@ class Comment extends React.Component { showSignInDialog, postLike, postFlag, + loadMore, setActiveReplyBox, activeReplyBox, deleteAction @@ -172,6 +174,17 @@ class Comment extends React.Component { comment={reply} />; }) } + { + comment.replies && +
+ comment.replies.length} + loadMore={loadMore}/> +
+ } ); } diff --git a/client/coral-embed-stream/src/Embed.js b/client/coral-embed-stream/src/Embed.js index e5eec37cb..d58107934 100644 --- a/client/coral-embed-stream/src/Embed.js +++ b/client/coral-embed-stream/src/Embed.js @@ -151,6 +151,7 @@ class Embed extends Component { currentUser={user} postLike={this.props.postLike} postFlag={this.props.postFlag} + loadMore={this.props.loadMore} deleteAction={this.props.deleteAction} showSignInDialog={this.props.showSignInDialog} comments={asset.comments} /> diff --git a/client/coral-embed-stream/src/LoadMore.js b/client/coral-embed-stream/src/LoadMore.js index e871af410..e07c1aa35 100644 --- a/client/coral-embed-stream/src/LoadMore.js +++ b/client/coral-embed-stream/src/LoadMore.js @@ -4,24 +4,29 @@ import translations from 'coral-framework/translations.json'; import {Button} from 'coral-ui'; const lang = new I18n(translations); -const loadMoreComments = (id, comments, loadMore) => { +const loadMoreComments = (id, comments, loadMore, parentId) => { if (!comments.length) { return; } + const cursor = parentId + ? comments[1].created_at + : comments[comments.length - 1].created_at; + loadMore({ limit: 10, - cursor: comments[comments.length - 1].created_at, + cursor, asset_id: id, - sort: 'REVERSE_CHRONOLOGICAL' + parent_id: parentId, + sort: parentId ? 'CHRONOLOGICAL' : 'REVERSE_CHRONOLOGICAL' }); }; -const LoadMore = ({id, comments, loadMore, moreComments}) => moreComments ? +const LoadMore = ({id, comments, loadMore, moreComments, parentId}) => moreComments ?