mirror of
https://github.com/wassname/talk.git
synced 2026-08-13 12:40:11 +08:00
replaced eslint:recommended with prettier
This commit is contained in:
@@ -1,19 +1,17 @@
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import {t} from 'plugin-api/beta/client/services';
|
||||
import { t } from 'plugin-api/beta/client/services';
|
||||
|
||||
/**
|
||||
* CheckToxicityHook adds hooks to the `commentBox`
|
||||
* that handles checking a comment for toxicity.
|
||||
*/
|
||||
export default class CheckToxicityHook extends React.Component {
|
||||
|
||||
// checked signifies if we already sent a request with the `checkToxicity` set to true.
|
||||
checked = false;
|
||||
|
||||
componentDidMount() {
|
||||
this.toxicityPreHook = this.props.registerHook('preSubmit', (input) => {
|
||||
|
||||
this.toxicityPreHook = this.props.registerHook('preSubmit', input => {
|
||||
// If we haven't check the toxicity yet, make sure to include `checkToxicity=true` in the mutation.
|
||||
// Otherwise post comment without checking the toxicity.
|
||||
if (!this.checked) {
|
||||
@@ -22,9 +20,15 @@ export default class CheckToxicityHook extends React.Component {
|
||||
}
|
||||
});
|
||||
|
||||
this.toxicityPostHook = this.props.registerHook('postSubmit', (result) => {
|
||||
this.toxicityPostHook = this.props.registerHook('postSubmit', result => {
|
||||
const actions = result.createComment.actions;
|
||||
if (actions && actions.some(({__typename, reason}) => __typename === 'FlagAction' && reason === 'TOXIC_COMMENT')) {
|
||||
if (
|
||||
actions &&
|
||||
actions.some(
|
||||
({ __typename, reason }) =>
|
||||
__typename === 'FlagAction' && reason === 'TOXIC_COMMENT'
|
||||
)
|
||||
) {
|
||||
this.props.notify('error', t('talk-plugin-toxic-comments.still_toxic'));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,35 +1,33 @@
|
||||
import React from 'react';
|
||||
import {CommentDetail} from 'plugin-api/beta/client/components';
|
||||
import {isToxic} from '../utils';
|
||||
import { CommentDetail } from 'plugin-api/beta/client/components';
|
||||
import { isToxic } from '../utils';
|
||||
import styles from './ToxicDetail.css';
|
||||
import cn from 'classnames';
|
||||
import PropTypes from 'prop-types';
|
||||
import {t} from 'plugin-api/beta/client/services';
|
||||
import { t } from 'plugin-api/beta/client/services';
|
||||
|
||||
const getInfo = (toxicity, actions) => {
|
||||
const toxic = isToxic(actions);
|
||||
let text = t('talk-plugin-toxic-comments.unlikely');
|
||||
if (toxicity > 0.8) {
|
||||
text = t('talk-plugin-toxic-comments.highly_likely');
|
||||
}
|
||||
else if (toxicity >= 0.5) {
|
||||
} else if (toxicity >= 0.5) {
|
||||
text = t('talk-plugin-toxic-comments.possibly');
|
||||
}
|
||||
else if (toxicity >= 0.7) {
|
||||
} else if (toxicity >= 0.7) {
|
||||
text = t('talk-plugin-toxic-comments.likely');
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
{text}
|
||||
<span className={cn(styles.info, {[styles.toxic]: toxic})}>
|
||||
<span className={cn(styles.info, { [styles.toxic]: toxic })}>
|
||||
{Math.round(toxicity * 100)}%
|
||||
</span>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
const ToxicLabel = ({comment: {actions, toxicity}}) => (
|
||||
const ToxicLabel = ({ comment: { actions, toxicity } }) => (
|
||||
<CommentDetail
|
||||
icon={'add_box'}
|
||||
header={t('talk-plugin-toxic-comments.toxic_comment')}
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
import React from 'react';
|
||||
import {FlagLabel} from 'plugin-api/beta/client/components/ui';
|
||||
import { FlagLabel } from 'plugin-api/beta/client/components/ui';
|
||||
|
||||
const ToxicLabel = () => (
|
||||
<FlagLabel iconName="add_box">Toxic</FlagLabel>
|
||||
);
|
||||
const ToxicLabel = () => <FlagLabel iconName="add_box">Toxic</FlagLabel>;
|
||||
|
||||
export default ToxicLabel;
|
||||
|
||||
Reference in New Issue
Block a user