Bugfixes and show different notification for toxic comments

Bugfixes:
- Toxic comment flag was not added
- GraphQL warnings for missing fields
This commit is contained in:
Chi Vinh Le
2017-09-19 19:20:38 +07:00
parent 262213a520
commit b5deac7b48
7 changed files with 56 additions and 15 deletions
@@ -123,6 +123,7 @@ export default {
optimisticResponse: {
createComment: {
__typename: 'CreateCommentResponse',
errors: null,
comment: {
__typename: 'Comment',
user: {
@@ -132,6 +133,7 @@ export default {
},
created_at: new Date().toISOString(),
body,
actions: [],
action_summaries: [],
tags: tags.map((tag) => ({
tag: {
+10 -1
View File
@@ -11,12 +11,20 @@ import {CommentForm} from './CommentForm';
export const name = 'talk-plugin-commentbox';
const notifyReasons = ['LINKS', 'TRUST'];
function shouldNotify(actions = []) {
return actions.some(({reason}) => notifyReasons.includes(reason));
}
// Given a newly posted comment's status, show a notification to the user
// if needed
export const notifyForNewCommentStatus = (notify, comment) => {
if (comment.status === 'REJECTED') {
notify('error', t('comment_box.comment_post_banned_word'));
} else if (comment.status === 'PREMOD' || comment.status === 'SYSTEM_WITHHELD') {
} else if (
comment.status === 'PREMOD' ||
comment.status === 'SYSTEM_WITHHELD' && shouldNotify(comment.actions)) {
notify('success', t('comment_box.comment_post_notif_premod'));
}
};
@@ -187,6 +195,7 @@ CommentBox.propTypes = {
isReply: PropTypes.bool.isRequired,
canPost: PropTypes.bool,
notify: PropTypes.func.isRequired,
commentBox: PropTypes.object,
};
const mapStateToProps = ({commentBox}) => ({commentBox});