mirror of
https://github.com/wassname/talk.git
synced 2026-08-11 05:54:07 +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:
@@ -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: {
|
||||
|
||||
@@ -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});
|
||||
|
||||
Reference in New Issue
Block a user