| 325 | } |
| 326 | |
| 327 | unlikeAComment(commentId) { |
| 328 | if (!this.accessToken) return Promise.reject() |
| 329 | |
| 330 | const reactions = this.state.commentReactions[commentId] |
| 331 | const comment = this.state.comments.find(comment => comment.id === commentId) |
| 332 | const { user } = this.state |
| 333 | const index = reactions.findIndex(reaction => reaction.user.login === user.login) |
| 334 | |
| 335 | return http.delete(`/reactions/${reactions[index].id}`) |
| 336 | .then(() => { |
| 337 | reactions.splice(index, 1) |
| 338 | comment.reactions.heart-- |
| 339 | }) |
| 340 | } |
| 341 | } |
| 342 | |
| 343 | module.exports = Gitment |