Error reporting for the rest

This commit is contained in:
Chi Vinh Le
2018-01-23 19:41:00 +01:00
parent 0523faee2b
commit ace6cbb158
8 changed files with 14 additions and 25 deletions
@@ -3,7 +3,6 @@ import PropTypes from 'prop-types';
import LoadMore from './LoadMore';
import NewCount from './NewCount';
import { TransitionGroup } from 'react-transition-group';
import { forEachError } from 'coral-framework/utils';
import Comment from '../containers/Comment';
import NoComments from './NoComments';
@@ -91,11 +90,8 @@ class AllCommentsPane extends React.Component {
.then(() => {
this.setState({ loadingState: 'success' });
})
.catch(error => {
.catch(() => {
this.setState({ loadingState: 'error' });
forEachError(error, ({ msg }) => {
this.props.notify('error', msg);
});
});
};
@@ -24,7 +24,6 @@ import { EditableCommentContent } from './EditableCommentContent';
import {
getActionSummary,
iPerformedThisAction,
forEachError,
isCommentActive,
getShallowChanges,
} from 'coral-framework/utils';
@@ -261,11 +260,8 @@ export default class Comment extends React.Component {
loadingState: 'success',
});
})
.catch(error => {
.catch(() => {
this.setState({ loadingState: 'error' });
forEachError(error, ({ msg }) => {
this.props.notify('error', msg);
});
});
emit('ui.Comment.showMoreReplies', { id });
return;
@@ -6,7 +6,6 @@ import styles from './Comment.css';
import { CountdownSeconds } from './CountdownSeconds';
import { getEditableUntilDate } from './util';
import { can } from 'coral-framework/services/perms';
import { forEachError } from 'coral-framework/utils';
import { Icon } from 'coral-ui';
import t from 'coral-framework/services/i18n';
@@ -80,7 +79,7 @@ export class EditableCommentContent extends React.Component {
this.setState({ loadingState: 'loading' });
const { editComment, notify, stopEditing } = this.props;
const { editComment, stopEditing } = this.props;
if (typeof editComment !== 'function') {
return;
}
@@ -95,7 +94,6 @@ export class EditableCommentContent extends React.Component {
}
} catch (error) {
this.setState({ loadingState: 'error' });
forEachError(error, ({ msg }) => notify('error', msg));
}
};
@@ -1,6 +1,6 @@
import React from 'react';
import PropTypes from 'prop-types';
import { StreamError } from './StreamError';
import StreamError from './StreamError';
import Comment from '../containers/Comment';
import BannedAccount from '../../../components/BannedAccount';
import ChangeUsername from '../containers/ChangeUsername';
@@ -1,6 +1,6 @@
import React from 'react';
import styles from './StreamError.css';
export const StreamError = ({ children }) => (
export default ({ children }) => (
<div className={styles.streamError}>{children}</div>
);
@@ -38,6 +38,7 @@ import {
insertFetchedCommentsIntoEmbedQuery,
nest,
} from '../../../graphql/utils';
import StreamError from '../components/StreamError';
const { showSignInDialog, editName } = authActions;
const { notify } = notificationActions;
@@ -208,6 +209,10 @@ class StreamContainer extends React.Component {
}
render() {
if (this.props.data.error) {
return <StreamError>{this.props.data.error.message}</StreamError>;
}
if (
!this.props.asset ||
(this.props.asset.comment === undefined && !this.props.asset.comments)
@@ -424,7 +429,8 @@ export default compose(
withEmit,
connect(mapStateToProps, mapDispatchToProps),
withPostComment,
withPostFlag,
// `talk-plugin-flags` has a custom error handling logic.
withPostFlag({ notifyOnError: false }),
withPostDontAgree,
withDeleteAction,
withEditComment
+1 -3
View File
@@ -3,7 +3,6 @@ import PropTypes from 'prop-types';
import t from 'coral-framework/services/i18n';
import { can } from 'coral-framework/services/perms';
import { forEachError } from 'coral-framework/utils';
import Slot from 'coral-framework/components/Slot';
import { connect } from 'react-redux';
@@ -93,9 +92,8 @@ class CommentBox extends React.Component {
commentPostedHandler();
}
})
.catch(err => {
.catch(() => {
this.setState({ loadingState: 'error' });
forEachError(err, ({ msg }) => notify('error', msg));
});
};
+1 -6
View File
@@ -2,7 +2,6 @@ import React from 'react';
import PropTypes from 'prop-types';
import Comment from './Comment';
import LoadMore from './LoadMore';
import { forEachError } from 'plugin-api/beta/client/utils';
class CommentHistory extends React.Component {
state = {
@@ -16,11 +15,8 @@ class CommentHistory extends React.Component {
.then(() => {
this.setState({ loadingState: 'success' });
})
.catch(error => {
.catch(() => {
this.setState({ loadingState: 'error' });
forEachError(error, ({ msg }) => {
this.props.notify('error', msg);
});
});
};
@@ -55,7 +51,6 @@ class CommentHistory extends React.Component {
CommentHistory.propTypes = {
comments: PropTypes.object.isRequired,
loadMore: PropTypes.func,
notify: PropTypes.func,
link: PropTypes.func,
data: PropTypes.object,
root: PropTypes.object,