mirror of
https://github.com/wassname/talk.git
synced 2026-09-10 12:43:11 +08:00
replaced eslint:recommended with prettier
This commit is contained in:
@@ -9,37 +9,67 @@ import styles from './CommentLabels.css';
|
||||
const staffRoles = ['ADMIN', 'STAFF', 'MODERATOR'];
|
||||
|
||||
function isUserFlagged(actions) {
|
||||
return actions.some((action) => action.__typename === 'FlagAction' && action.user);
|
||||
return actions.some(
|
||||
action => action.__typename === 'FlagAction' && action.user
|
||||
);
|
||||
}
|
||||
|
||||
function getUserFlaggedType(actions) {
|
||||
return actions
|
||||
.some((action) =>
|
||||
return actions.some(
|
||||
action =>
|
||||
action.__typename === 'FlagAction' &&
|
||||
action.user &&
|
||||
staffRoles.includes(action.user.role)
|
||||
) ? 'Staff' : 'User';
|
||||
)
|
||||
? 'Staff'
|
||||
: 'User';
|
||||
}
|
||||
|
||||
function hasSuspectedWords(actions) {
|
||||
return actions.some((action) => action.__typename === 'FlagAction' && action.reason === 'SUSPECT_WORD');
|
||||
return actions.some(
|
||||
action =>
|
||||
action.__typename === 'FlagAction' && action.reason === 'SUSPECT_WORD'
|
||||
);
|
||||
}
|
||||
|
||||
function hasHistoryFlag(actions) {
|
||||
return actions.some((action) => action.__typename === 'FlagAction' && action.reason === 'TRUST');
|
||||
return actions.some(
|
||||
action => action.__typename === 'FlagAction' && action.reason === 'TRUST'
|
||||
);
|
||||
}
|
||||
|
||||
const CommentLabels = ({comment, comment: {className, status, actions, hasParent}}) => {
|
||||
const CommentLabels = ({
|
||||
comment,
|
||||
comment: { className, status, actions, hasParent },
|
||||
}) => {
|
||||
return (
|
||||
<div className={cn(className, styles.root)}>
|
||||
<div className={styles.coreLabels}>
|
||||
{hasParent && <Label iconName="reply" className={styles.replyLabel}>reply</Label>}
|
||||
{status === 'PREMOD' && <Label iconName="query_builder" className={styles.premodLabel}>Pre-Mod</Label>}
|
||||
{isUserFlagged(actions) && <FlagLabel iconName="person">{getUserFlaggedType(actions)}</FlagLabel>}
|
||||
{hasSuspectedWords(actions) && <FlagLabel iconName="sms_failed">Suspect</FlagLabel>}
|
||||
{hasHistoryFlag(actions) && <FlagLabel iconName="sentiment_very_dissatisfied">History</FlagLabel>}
|
||||
{hasParent && (
|
||||
<Label iconName="reply" className={styles.replyLabel}>
|
||||
reply
|
||||
</Label>
|
||||
)}
|
||||
{status === 'PREMOD' && (
|
||||
<Label iconName="query_builder" className={styles.premodLabel}>
|
||||
Pre-Mod
|
||||
</Label>
|
||||
)}
|
||||
{isUserFlagged(actions) && (
|
||||
<FlagLabel iconName="person">{getUserFlaggedType(actions)}</FlagLabel>
|
||||
)}
|
||||
{hasSuspectedWords(actions) && (
|
||||
<FlagLabel iconName="sms_failed">Suspect</FlagLabel>
|
||||
)}
|
||||
{hasHistoryFlag(actions) && (
|
||||
<FlagLabel iconName="sentiment_very_dissatisfied">History</FlagLabel>
|
||||
)}
|
||||
</div>
|
||||
<Slot className={styles.slot} fill="adminCommentLabels" queryData={{comment}} />
|
||||
<Slot
|
||||
className={styles.slot}
|
||||
fill="adminCommentLabels"
|
||||
queryData={{ comment }}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user