diff --git a/web/app/components/comment/comment.jsx b/web/app/components/comment/comment.jsx index d957d420..04d11a7f 100644 --- a/web/app/components/comment/comment.jsx +++ b/web/app/components/comment/comment.jsx @@ -33,16 +33,25 @@ export default class Comment extends Component { } updateState(props) { - const { user: { block }, pin, score = 0, votes = [] } = props.data; - const userId = store.get('user').id; + const { data: { user: { block }, pin, score = 0, votes = [] }, mods: { guest } = {} } = props; - this.setState({ - score: score, - pinned: !!pin, - userBlocked: !!block, - scoreIncreased: userId in votes && votes[userId], - scoreDecreased: userId in votes && !votes[userId], - }); + if (guest) { + this.setState({ + guest, + score, + }); + } else { + const userId = store.get('user').id; + + this.setState({ + guest, + score, + pinned: !!pin, + userBlocked: !!block, + scoreIncreased: userId in votes && votes[userId], + scoreDecreased: userId in votes && !votes[userId], + }); + } } onReplyClick() { @@ -138,10 +147,10 @@ export default class Comment extends Component { this.setState({ isInputVisible: false }); } - render(props, { userBlocked, pinned, score, scoreIncreased, scoreDecreased, isInputVisible }) { + render(props, { guest, userBlocked, pinned, score, scoreIncreased, scoreDecreased, isInputVisible }) { const { data, mix, mods = {} } = props; - const isAdmin = store.get('user').admin; - const isGuest = !Object.keys(store.get('user')).length; + const isAdmin = !guest && store.get('user').admin; + const isGuest = guest || !Object.keys(store.get('user')).length; const time = new Date(data.time); // TODO: which format for datetime should we choose? @@ -179,26 +188,25 @@ export default class Comment extends Component {
{o.user.name} - - { - !isGuest && ( + { + !isGuest && ( + vote up - ) - } - {o.score.sign} - {o.score.value} - { - !isGuest && ( + + {o.score.sign} + + {o.score.value} + vote down - ) - } - + + ) + } {o.time}