From b43649e22e5a559b5bf5a7efca022539d385d8cf Mon Sep 17 00:00:00 2001 From: JP Rodrigues <70jprodrigues@gmail.com> Date: Sun, 30 May 2021 16:40:35 -0300 Subject: [PATCH] Fix comment deletion --- package.json | 2 +- src/components/SentimentItem/index.js | 86 +++++++++++++++------------ 2 files changed, 49 insertions(+), 39 deletions(-) diff --git a/package.json b/package.json index 17ad8dc..dcc1bc3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "lyzeli", - "version": "1.3.0", + "version": "1.3.1", "private": true, "dependencies": { "@popperjs/core": "^2.9.2", diff --git a/src/components/SentimentItem/index.js b/src/components/SentimentItem/index.js index e7a81cb..4e61a17 100644 --- a/src/components/SentimentItem/index.js +++ b/src/components/SentimentItem/index.js @@ -22,7 +22,7 @@ export default class SentimentItem extends Component { } handleDelete(tag) { - return this.props.onRemoveComment(tag); + this.props.onRemoveComment(tag); } change = (color) => { @@ -43,7 +43,9 @@ export default class SentimentItem extends Component { if (comments && comments[this.props.type.key]) { const result = {}; - const authors = Object.keys(comments[this.props.type.key]); + const authors = Object.keys(comments[this.props.type.key]).filter( + (a) => a !== "Consensus" + ); if (authors.length > 1) { authors.forEach((author) => { const opinions = comments[this.props.type.key][author]; @@ -70,8 +72,11 @@ export default class SentimentItem extends Component { const { answer, sentiment, sentimentManual } = this.props.item; const comments = { ...this.props.item.comments }; const consensus = this.consensus(); + if (consensus && consensus.length) { comments[this.props.type.key]["Consensus"] = consensus; + } else if (comments[this.props.type.key]) { + delete comments[this.props.type.key]["Consensus"]; } let authors = []; @@ -118,44 +123,49 @@ export default class SentimentItem extends Component {
{authors.map((i) => { const author = i.split("@"); - - return ( -
-
- {author.length > 1 ? ( - <> - {author[0]} - +
+ {author.length > 1 ? ( + <> + {author[0]} + + @{author[0]} + + + ) : ( + + {author} + + )} +
+
+ {comments[this.props.type.key][i].map((j) => ( + this.handleDelete(j)} > - @{author[0]} - - - ) : ( - - {author} - - )} -
-
- {comments[this.props.type.key][i].map((j) => ( - this.handleDelete(j)} - > - {j.text} - - ))} + {j.text} + + ))} +
-
- ); + ); + } + return ""; })}