Tiny refactor..

This commit is contained in:
Chi Vinh Le
2017-08-18 19:50:56 +07:00
parent 6a5f6e3ce1
commit 8eaac3eaa2
3 changed files with 49 additions and 45 deletions
@@ -51,7 +51,7 @@ class ProfileContainer extends Component {
};
render() {
const {auth, auth: {user}, asset, showSignInDialog, stopIgnoringUser} = this.props;
const {auth, auth: {user}, showSignInDialog, stopIgnoringUser, root, data} = this.props;
const {me} = this.props.root;
const loading = this.props.data.loading;
@@ -87,7 +87,7 @@ class ProfileContainer extends Component {
<h3>{t('framework.my_comments')}</h3>
{me.comments.nodes.length
? <CommentHistory comments={me.comments} asset={asset} link={link} loadMore={this.loadMore}/>
? <CommentHistory data={data} root={root} comments={me.comments} link={link} loadMore={this.loadMore}/>
: <p>{t('user_no_comment')}</p>}
</div>
);
@@ -138,7 +138,6 @@ const withProfileQuery = withQuery(
`);
const mapStateToProps = (state) => ({
asset: state.asset,
auth: state.auth
});
+43 -40
View File
@@ -7,54 +7,57 @@ import CommentContent from '../coral-embed-stream/src/components/CommentContent'
import t from 'coral-framework/services/i18n';
const Comment = (props) => {
return (
<div className={styles.myComment}>
<div>
<Slot
fill="commentContent"
defaultComponent={CommentContent}
className={`${styles.commentBody} myCommentBody`}
comment={props.comment}
/>
<p className="myCommentAsset">
<a
className={`${styles.assetURL} myCommentAnchor`}
href="#"
onClick={props.link(`${props.asset.url}`)}>
Story: {props.asset.title ? props.asset.title : props.asset.url}
</a>
</p>
</div>
<div className={styles.sidebar}>
<ul>
<li>
<a onClick={props.link(`${props.asset.url}?commentId=${props.comment.id}`)}>
<Icon name="open_in_new" className={styles.iconView}/>{t('view_conversation')}
class Comment extends React.Component {
render() {
const {comment, link, data, root} = this.props;
return (
<div className={styles.myComment}>
<div>
<Slot
fill="commentContent"
defaultComponent={CommentContent}
className={`${styles.commentBody} myCommentBody`}
data={data}
root={root}
comment={comment}
asset={comment.asset}
/>
<p className="myCommentAsset">
<a
className={`${styles.assetURL} myCommentAnchor`}
href="#"
onClick={link(`${comment.asset.url}`)}>
Story: {comment.asset.title ? comment.asset.title : comment.asset.url}
</a>
</li>
<li>
<Icon name="schedule" className={styles.iconDate}/>
<PubDate
className={styles.pubdate}
created_at={props.comment.created_at}
/>
</li>
</ul>
</p>
</div>
<div className={styles.sidebar}>
<ul>
<li>
<a onClick={link(`${comment.asset.url}?commentId=${comment.id}`)}>
<Icon name="open_in_new" className={styles.iconView}/>{t('view_conversation')}
</a>
</li>
<li>
<Icon name="schedule" className={styles.iconDate}/>
<PubDate
className={styles.pubdate}
created_at={comment.created_at}
/>
</li>
</ul>
</div>
</div>
</div>
);
};
);
}
}
Comment.propTypes = {
comment: PropTypes.shape({
id: PropTypes.string,
body: PropTypes.string
}).isRequired,
asset: PropTypes.shape({
url: PropTypes.string,
title: PropTypes.string
}).isRequired
};
export default Comment;
+4 -2
View File
@@ -22,16 +22,18 @@ class CommentHistory extends React.Component {
}
render() {
const {link, comments} = this.props;
const {link, comments, data, root} = this.props;
return (
<div className={`${styles.header} commentHistory`}>
<div className="commentHistory__list">
{comments.nodes.map((comment, i) => {
return <Comment
key={i}
data={data}
root={root}
comment={comment}
link={link}
asset={comment.asset} />;
/>;
})}
</div>
{comments.hasNextPage &&