mirror of
https://github.com/wassname/talk.git
synced 2026-07-19 11:28:50 +08:00
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:
@@ -1,4 +1,6 @@
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import {t} from 'plugin-api/beta/client/services';
|
||||
|
||||
/**
|
||||
* CheckToxicityHook adds hooks to the `commentBox`
|
||||
@@ -20,7 +22,11 @@ export default class CheckToxicityHook extends React.Component {
|
||||
}
|
||||
});
|
||||
|
||||
this.toxicityPostHook = this.props.registerHook('postSubmit', () => {
|
||||
this.toxicityPostHook = this.props.registerHook('postSubmit', (result) => {
|
||||
const actions = result.createComment.comment && result.createComment.comment.actions;
|
||||
if (actions && actions.some(({reason}) => reason === 'TOXIC_COMMENT')) {
|
||||
this.props.notify('error', t('talk-plugin-toxic-comments.still_toxic'));
|
||||
}
|
||||
|
||||
// Reset `checked` after comment was successfully posted.
|
||||
this.checked = false;
|
||||
@@ -36,3 +42,9 @@ export default class CheckToxicityHook extends React.Component {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
CheckToxicityHook.propTypes = {
|
||||
notify: PropTypes.func.isRequired,
|
||||
registerHook: PropTypes.func.isRequired,
|
||||
unregisterHook: PropTypes.func.isRequired,
|
||||
};
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
import {bindActionCreators} from 'redux';
|
||||
import {connect} from 'plugin-api/beta/client/hocs';
|
||||
import {notify} from 'plugin-api/beta/client/actions/notification';
|
||||
import CheckToxicityHook from '../components/CheckToxicityHook';
|
||||
|
||||
const mapDispatchToProps = (dispatch) =>
|
||||
bindActionCreators({notify}, dispatch);
|
||||
|
||||
export default connect(null, mapDispatchToProps)(CheckToxicityHook);
|
||||
@@ -1,5 +1,5 @@
|
||||
import translations from './translations.yml';
|
||||
import CheckToxicityHook from './components/CheckToxicityHook';
|
||||
import CheckToxicityHook from './containers/CheckToxicityHook';
|
||||
|
||||
export default {
|
||||
translations,
|
||||
|
||||
@@ -3,4 +3,8 @@ en:
|
||||
COMMENT_IS_TOXIC: |
|
||||
Are you sure? The language in this comment might violate our community guidelines.
|
||||
You can edit the comment or submit it for moderator review.
|
||||
talk-plugin-toxic-comments:
|
||||
still_toxic: |
|
||||
This edited comment might still violate our community guidelines.
|
||||
Our moderation team will review your comment shortly.
|
||||
es:
|
||||
|
||||
Reference in New Issue
Block a user