From e54d9797072532c7923e8bb342a5287edcccdc0c Mon Sep 17 00:00:00 2001 From: igoradamenko Date: Sat, 12 May 2018 00:28:58 +0300 Subject: [PATCH] don't allow user to vote for his own comment --- web/app/common/store.js | 4 +++- web/app/components/comment/comment.jsx | 9 +++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/web/app/common/store.js b/web/app/common/store.js index 0f033f24..9e5fda31 100644 --- a/web/app/common/store.js +++ b/web/app/common/store.js @@ -110,7 +110,9 @@ class Store { } getPinnedComments() { - return this.data.comments.reduce((acc, thread) => acc.concat(findPinnedComments(thread)), []); + const comments = this.data.comments || []; + + return comments.reduce((acc, thread) => acc.concat(findPinnedComments(thread)), []); } } diff --git a/web/app/components/comment/comment.jsx b/web/app/components/comment/comment.jsx index 17dcde07..ff092674 100644 --- a/web/app/components/comment/comment.jsx +++ b/web/app/components/comment/comment.jsx @@ -185,6 +185,7 @@ export default class Comment extends Component { const { data, mix, mods = {} } = props; const isAdmin = !guest && store.get('user').admin; const isGuest = guest || !Object.keys(store.get('user')).length; + const isCurrentUser = (data.user && data.user.id) === (store.get('user') && store.get('user').id); const o = { ...data, @@ -274,9 +275,9 @@ export default class Comment extends Component { Vote up @@ -285,9 +286,9 @@ export default class Comment extends Component { Vote down