mirror of
https://github.com/wassname/talk.git
synced 2026-08-09 12:30:42 +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,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user