mirror of
https://github.com/wassname/talk.git
synced 2026-07-04 19:50:17 +08:00
No need to handle errors here
This commit is contained in:
@@ -1,28 +1,16 @@
|
||||
import React from 'react';
|
||||
import {getErrorMessages} from 'plugin-api/beta/client/utils';
|
||||
import {withSetCommentStatus} from 'plugin-api/beta/client/hocs';
|
||||
import {notify} from 'plugin-api/beta/client/actions/notification';
|
||||
import ApproveCommentAction from '../components/ApproveCommentAction';
|
||||
import isNil from 'lodash/isNil';
|
||||
|
||||
class ApproveCommentActionContainer extends React.Component {
|
||||
|
||||
approveComment = async () => {
|
||||
approveComment = () => {
|
||||
const {setCommentStatus, comment} = this.props;
|
||||
|
||||
try {
|
||||
const result = await setCommentStatus({
|
||||
commentId: comment.id,
|
||||
status: 'ACCEPTED'
|
||||
});
|
||||
|
||||
if (!isNil(result.data.setCommentStatus)) {
|
||||
throw result.data.setCommentStatus.errors;
|
||||
}
|
||||
|
||||
} catch (err) {
|
||||
notify('error', getErrorMessages(err));
|
||||
}
|
||||
setCommentStatus({
|
||||
commentId: comment.id,
|
||||
status: 'ACCEPTED'
|
||||
});
|
||||
}
|
||||
|
||||
render() {
|
||||
|
||||
@@ -1,28 +1,16 @@
|
||||
import React from 'react';
|
||||
import {getErrorMessages} from 'plugin-api/beta/client/utils';
|
||||
import {withSetCommentStatus} from 'plugin-api/beta/client/hocs';
|
||||
import {notify} from 'plugin-api/beta/client/actions/notification';
|
||||
import RejectCommentAction from '../components/RejectCommentAction';
|
||||
import isNil from 'lodash/isNil';
|
||||
|
||||
class RejectCommentActionContainer extends React.Component {
|
||||
|
||||
rejectComment = async () => {
|
||||
rejectComment = () => {
|
||||
const {setCommentStatus, comment} = this.props;
|
||||
|
||||
try {
|
||||
const result = await setCommentStatus({
|
||||
commentId: comment.id,
|
||||
status: 'REJECTED'
|
||||
});
|
||||
|
||||
if (!isNil(result.data.setCommentStatus)) {
|
||||
throw result.data.setCommentStatus.errors;
|
||||
}
|
||||
|
||||
} catch (err) {
|
||||
notify('error', getErrorMessages(err));
|
||||
}
|
||||
setCommentStatus({
|
||||
commentId: comment.id,
|
||||
status: 'REJECTED'
|
||||
});
|
||||
}
|
||||
|
||||
render() {
|
||||
|
||||
Reference in New Issue
Block a user