diff --git a/client/coral-embed-stream/src/Comment.js b/client/coral-embed-stream/src/Comment.js
index 6e3744aab..21e98ae64 100644
--- a/client/coral-embed-stream/src/Comment.js
+++ b/client/coral-embed-stream/src/Comment.js
@@ -11,103 +11,157 @@ import PermalinkButton from 'coral-plugin-permalinks/PermalinkButton';
// import AuthorName from '../../coral-plugin-author-name/AuthorName';
import Content from '../../coral-plugin-commentcontent/CommentContent';
import PubDate from '../../coral-plugin-pubdate/PubDate';
-// import {ReplyBox, ReplyButton} from '../../coral-plugin-replies';
+import {ReplyBox, ReplyButton} from 'coral-plugin-replies';
import FlagComment from '../../coral-plugin-flags/FlagComment';
import LikeButton from '../../coral-plugin-likes/LikeButton';
const getAction = (type, comment) => comment.actions.filter((a) => a.type === type)[0];
-const Comment = ({comment, currentUser, asset, depth, showSignInDialog, postAction, deleteAction}) => {
- const like = getAction('LIKE', comment);
- const flag = getAction('FLAG', comment);
- return (
-
+ {
+ this.state.replyBoxVisible
+ ?
+ : null
+ }
+ {
+ comment.replies &&
+ comment.replies.map(reply => {
+ return ;
+ })
+ }
-Comment.propTypes = {
- depth: PropTypes.number.isRequired,
- asset: PropTypes.shape({
- id: PropTypes.string,
- title: PropTypes.string,
- url: PropTypes.string
- }).isRequired,
- currentUser: PropTypes.object,
- comment: PropTypes.shape({
- depth: PropTypes.number,
- actions: PropTypes.array.isRequired,
- body: PropTypes.string.isRequired,
- id: PropTypes.string.isRequired,
- replies: PropTypes.arrayOf(
- PropTypes.shape({
- body: PropTypes.string.isRequired,
- id: PropTypes.string.isRequired
- })
- ),
- user: PropTypes.shape({
- id: PropTypes.string.isRequired,
- name: PropTypes.string.isRequired
- }).isRequired
- }).isRequired
-};
+
+ );
+ }
+}
export default Comment;
diff --git a/client/coral-embed-stream/src/Embed.js b/client/coral-embed-stream/src/Embed.js
index cd55c13cd..8ddc215cb 100644
--- a/client/coral-embed-stream/src/Embed.js
+++ b/client/coral-embed-stream/src/Embed.js
@@ -102,7 +102,7 @@ class Embed extends Component {
// const banned = (this.props.userData.status === 'banned');
- const {loading, asset} = this.props.data;
+ const {loading, asset, refetch} = this.props.data;
// const {status, moderation, closedMessage, charCount, charCountEnable} = asset.settings;
@@ -129,24 +129,31 @@ class Embed extends Component {
enable={asset.settings.infoBoxEnable}
/>
}>
-
+ {
+ user
+ ?
+ : null
+ }
: {asset.settings.closedMessage}
}
{!loggedIn && }
{
+const Stream = ({comments, currentUser, asset, postItem, addNotification, postAction, deleteAction, showSignInDialog}) => {
return (
{
comments.map(comment => {
return
({
- postItem: ({asset_id, body}) => {
+ postItem: ({asset_id, body, parent_id} /*, type */) => {
return mutate({
variables: {
asset_id,
body,
- parent_id: null
+ parent_id
}
});
}}),
diff --git a/client/coral-plugin-commentbox/CommentBox.js b/client/coral-plugin-commentbox/CommentBox.js
index ff9bf7e39..90113180c 100644
--- a/client/coral-plugin-commentbox/CommentBox.js
+++ b/client/coral-plugin-commentbox/CommentBox.js
@@ -8,11 +8,13 @@ const name = 'coral-plugin-commentbox';
class CommentBox extends Component {
static propTypes = {
- postItem: PropTypes.func,
- updateItem: PropTypes.func,
- id: PropTypes.string,
- comments: PropTypes.array,
- reply: PropTypes.bool,
+ postItem: PropTypes.func.isRequired,
+ // updateItem: PropTypes.func,
+ assetId: PropTypes.string.isRequired,
+ parentId: PropTypes.string,
+ authorId: PropTypes.string.isRequired,
+ // comments: PropTypes.array,
+ isReply: PropTypes.bool.isRequired,
canPost: PropTypes.bool,
currentUser: PropTypes.object
}
@@ -25,33 +27,36 @@ class CommentBox extends Component {
postComment = () => {
const {
postItem,
- updateItem,
- id,
- parent_id,
- child_id,
+ // updateItem,
+ assetId,
+ parentId,
+ // child_id,
addNotification,
- appendItemArray,
- author
+ // appendItemArray,
+ authorId
} = this.props;
let comment = {
body: this.state.body,
- asset_id: id,
- author_id: author.id
+ asset_id: assetId,
+ author_id: authorId,
+ parent_id: parentId
};
- let related;
- let parent_type;
- if (parent_id) {
- comment.parent_id = parent_id;
- related = 'children';
- parent_type = 'comments';
- } else {
- related = 'comments';
- parent_type = 'assets';
- }
- if (child_id || parent_id) {
- updateItem(child_id || parent_id, 'showReply', false, 'comments');
- }
+
+ console.log('CommentBox.parentId', parentId);
+ // let related;
+ // let parent_type;
+ // if (parent_id) {
+ // comment.parent_id = parent_id;
+ // related = 'children';
+ // parent_type = 'comments';
+ // } else {
+ // related = 'comments';
+ // parent_type = 'assets';
+ // }
+ // if (child_id || parent_id) {
+ // updateItem(child_id || parent_id, 'showReply', false, 'comments');
+ // }
if (this.props.charCount && this.state.body.length > this.props.charCount) {
return;
@@ -59,13 +64,13 @@ class CommentBox extends Component {
postItem(comment, 'comments')
.then(({data}) => {
const postedComment = data.createComment;
- const commentId = postedComment.id;
+ // const commentId = postedComment.id;
if (postedComment.status === 'rejected') {
addNotification('error', lang.t('comment-post-banned-word'));
} else if (postedComment.status === 'PREMOD') {
addNotification('success', lang.t('comment-post-notif-premod'));
} else {
- appendItemArray(parent_id || id, related, commentId, !parent_id, parent_type);
+ // appendItemArray(parent_id || id, related, commentId, !parent_id, parent_type);
addNotification('success', 'Your comment has been posted.');
}
})
@@ -74,23 +79,23 @@ class CommentBox extends Component {
}
render () {
- const {styles, reply, author, charCount} = this.props;
+ const {styles, isReply, authorId, charCount} = this.props;
const length = this.state.body.length;
return
@@ -101,7 +106,7 @@ class CommentBox extends Component {
}
- { author && (
+ { authorId && (