From 94244f9751bb5f9dd44ec3a85c8fcc529b564af3 Mon Sep 17 00:00:00 2001 From: igoradamenko Date: Tue, 13 Feb 2018 00:53:02 +0200 Subject: [PATCH] decrease opacity of comments of banned users --- .../comment_pinned.scss} | 2 +- .../comment/_useless/comment_useless.scss | 5 +++++ web/app/components/comment/comment.jsx | 19 +++++++++++-------- web/app/components/comment/index.js | 4 +++- web/app/components/root/root.jsx | 2 +- 5 files changed, 21 insertions(+), 11 deletions(-) rename web/app/components/comment/{_marked/comment_marked.scss => _pinned/comment_pinned.scss} (86%) create mode 100644 web/app/components/comment/_useless/comment_useless.scss diff --git a/web/app/components/comment/_marked/comment_marked.scss b/web/app/components/comment/_pinned/comment_pinned.scss similarity index 86% rename from web/app/components/comment/_marked/comment_marked.scss rename to web/app/components/comment/_pinned/comment_pinned.scss index dc66b124..b7950eaf 100644 --- a/web/app/components/comment/_marked/comment_marked.scss +++ b/web/app/components/comment/_pinned/comment_pinned.scss @@ -1,6 +1,6 @@ @import 'common/variables'; -.comment_marked { +.comment_pinned { &, &.comment_view_admin { .comment__username { font-weight: 700; diff --git a/web/app/components/comment/_useless/comment_useless.scss b/web/app/components/comment/_useless/comment_useless.scss new file mode 100644 index 00000000..17d1393b --- /dev/null +++ b/web/app/components/comment/_useless/comment_useless.scss @@ -0,0 +1,5 @@ +.comment_useless { + .comment__body { + opacity: .35; + } +} diff --git a/web/app/components/comment/comment.jsx b/web/app/components/comment/comment.jsx index c4f79990..855214d7 100644 --- a/web/app/components/comment/comment.jsx +++ b/web/app/components/comment/comment.jsx @@ -71,28 +71,30 @@ export default class Comment extends Component { } onBlockClick() { - const { user: { id } } = this.props.data; + const { id, user: { id: userId } } = this.props.data; this.setState({ userBlocked: true }); - api.blockUser({ id }); + api.blockUser({ id: userId }).then(() => { + api.getComment({ id }).then(comment => store.replaceComment(comment)); + }); } onUnblockClick() { - const { user: { id } } = this.props.data; + const { id, user: { id: userId } } = this.props.data; this.setState({ userBlocked: false }); - api.unblockUser({ id }); + api.unblockUser({ id: userId }).then(() => { + api.getComment({ id }).then(comment => store.replaceComment(comment)); + }); } onDeleteClick() { const { id } = this.props.data; api.remove({ id }).then(() => { - if (this.props.onDelete) { - this.props.onDelete(); - } + api.getComment({ id }).then(comment => store.replaceComment(comment)); }); } @@ -156,7 +158,8 @@ export default class Comment extends Component { }; const defaultMods = { - marked: mods.pinned ? null : pinned, + pinned, + useless: userBlocked, // TODO: add default view mod or don't? view: o.user.admin ? 'admin' : null, }; diff --git a/web/app/components/comment/index.js b/web/app/components/comment/index.js index 9a5eee85..ba153c6c 100644 --- a/web/app/components/comment/index.js +++ b/web/app/components/comment/index.js @@ -25,6 +25,8 @@ require('./__vote/_type/_up/comment__vote_type_up.scss'); require('./_level/comment_level.scss'); -require('./_marked/comment_marked.scss'); +require('./_pinned/comment_pinned.scss'); + +require('./_useless/comment_useless.scss'); require('./_view/_admin/comment_view_admin.scss'); diff --git a/web/app/components/root/root.jsx b/web/app/components/root/root.jsx index cc10b8a3..59884ceb 100644 --- a/web/app/components/root/root.jsx +++ b/web/app/components/root/root.jsx @@ -67,7 +67,7 @@ export default class Root extends Component { pinnedComments.map(comment => ( ))