mirror of
https://github.com/wassname/talk.git
synced 2026-09-12 13:01:11 +08:00
Show notification upon failure
This commit is contained in:
@@ -8,6 +8,7 @@ import withMutation from 'coral-framework/hocs/withMutation';
|
|||||||
import withFragments from 'coral-framework/hocs/withFragments';
|
import withFragments from 'coral-framework/hocs/withFragments';
|
||||||
import {showSignInDialog} from 'coral-framework/actions/auth';
|
import {showSignInDialog} from 'coral-framework/actions/auth';
|
||||||
import {addNotification} from 'coral-framework/actions/notification';
|
import {addNotification} from 'coral-framework/actions/notification';
|
||||||
|
import {forEachError} from 'coral-framework/utils';
|
||||||
|
|
||||||
export default (tag) => (WrappedComponent) => {
|
export default (tag) => (WrappedComponent) => {
|
||||||
if (typeof tag !== 'string') {
|
if (typeof tag !== 'string') {
|
||||||
@@ -27,10 +28,10 @@ export default (tag) => (WrappedComponent) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const isTagged = (tags) =>
|
const isTagged = (tags) =>
|
||||||
!!tags.filter((t) => t.tag.name === Tag.toUpperCase()).length;
|
!!tags.filter((t) => t.tag.name === Tag.toUpperCase()).length;
|
||||||
|
|
||||||
const withAddTag = withMutation(
|
const withAddTag = withMutation(
|
||||||
gql`
|
gql`
|
||||||
mutation AddTag($id: ID!, $asset_id: ID!, $name: String!) {
|
mutation AddTag($id: ID!, $asset_id: ID!, $name: String!) {
|
||||||
@@ -112,29 +113,35 @@ export default (tag) => (WrappedComponent) => {
|
|||||||
});
|
});
|
||||||
}}),
|
}}),
|
||||||
});
|
});
|
||||||
|
|
||||||
class WithTags extends React.Component {
|
class WithTags extends React.Component {
|
||||||
|
|
||||||
postTag = () => {
|
postTag = () => {
|
||||||
const {comment, asset} = this.props;
|
const {comment, asset, addNotification} = this.props;
|
||||||
|
|
||||||
this.props.addTag({
|
this.props.addTag({
|
||||||
id: comment.id,
|
id: comment.id,
|
||||||
name: Tag.toUpperCase(),
|
name: Tag.toUpperCase(),
|
||||||
assetId: asset.id
|
assetId: asset.id
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
forEachError(err, ({msg}) => addNotification('error', msg));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
deleteTag = () => {
|
deleteTag = () => {
|
||||||
const {comment, asset} = this.props;
|
const {comment, asset, addNotification} = this.props;
|
||||||
|
|
||||||
this.props.removeTag({
|
this.props.removeTag({
|
||||||
id: comment.id,
|
id: comment.id,
|
||||||
name: Tag.toUpperCase(),
|
name: Tag.toUpperCase(),
|
||||||
assetId: asset.id
|
assetId: asset.id
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
forEachError(err, ({msg}) => addNotification('error', msg));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const {comment} = this.props;
|
const {comment} = this.props;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user