mirror of
https://github.com/wassname/talk.git
synced 2026-07-09 07:12:09 +08:00
Tiny refactor..
This commit is contained in:
@@ -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
|
||||
});
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 &&
|
||||
|
||||
Reference in New Issue
Block a user