From 1c2ef760eff744f93121ac5708bfbdabff006730 Mon Sep 17 00:00:00 2001 From: Riley Davis Date: Fri, 9 Dec 2016 11:46:04 -1000 Subject: [PATCH] remove cruft by pulling out some immutable.js stuff --- client/coral-admin/src/components/Comment.js | 27 +++++++++++--------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/client/coral-admin/src/components/Comment.js b/client/coral-admin/src/components/Comment.js index 380a001c8..be656c22d 100644 --- a/client/coral-admin/src/components/Comment.js +++ b/client/coral-admin/src/components/Comment.js @@ -14,18 +14,19 @@ const linkify = new Linkify(); // Render a single comment for the list export default props => { - const authorStatus = props.author.get('status'); - const {comment, author} = props; - const links = linkify.getMatches(comment.get('body')); + const comment = props.comment.toJS(); + const author = props.author.toJS(); + let authorStatus = author.status; + const links = linkify.getMatches(comment.body); return (
  • person - {author.get('displayName') || lang.t('comment.anon')} - {timeago().format(comment.get('createdAt') || (Date.now() - props.index * 60 * 1000), lang.getLocale().replace('-', '_'))} - {comment.get('flagged') ?

    {lang.t('comment.flagged')}

    : null} + {author.displayName || lang.t('comment.anon')} + {timeago().format(comment.createdAt || (Date.now() - props.index * 60 * 1000), lang.getLocale().replace('-', '_'))} + {comment.flagged ?

    {lang.t('comment.flagged')}

    : null}
    {links ? @@ -42,7 +43,7 @@ export default props => {
    - {comment.get('body')} + {comment.body}
    @@ -52,9 +53,11 @@ export default props => { // Get the button of the action performed over a comment if any const getActionButton = (action, i, props) => { - const status = props.comment.get('status'); - const flagged = props.comment.get('flagged'); - const banned = (props.author.get('status') === 'banned'); + const comment = props.comment.toJS(); + const author = props.author.toJS(); + const status = comment.status; + const flagged = comment.flagged; + const banned = (author.status === 'banned'); if (action === 'flag' && (status || flagged === true)) { return null; @@ -64,7 +67,7 @@ const getActionButton = (action, i, props) => { @@ -74,7 +77,7 @@ const getActionButton = (action, i, props) => { props.onClickAction(props.actionsMap[action].status, props.comment.get('id'))} + onClick={() => props.onClickAction(props.actionsMap[action].status, comment.id)} /> ); };