Refactor isFeatured / isTagged

This commit is contained in:
Chi Vinh Le
2017-07-18 21:10:59 +07:00
parent cf56ca8263
commit 8a619a219f
5 changed files with 8 additions and 12 deletions
+2 -5
View File
@@ -7,7 +7,7 @@ import {capitalize} from 'coral-framework/helpers/strings';
import withMutation from 'coral-framework/hocs/withMutation';
import withFragments from 'coral-framework/hocs/withFragments';
import {addNotification} from 'coral-framework/actions/notification';
import {forEachError} from 'coral-framework/utils';
import {forEachError, isTagged} from 'coral-framework/utils';
export default (tag) => (WrappedComponent) => {
if (typeof tag !== 'string') {
@@ -28,9 +28,6 @@ export default (tag) => (WrappedComponent) => {
}
`;
const isTagged = (tags) =>
!!tags.filter((t) => t.tag.name === Tag.toUpperCase()).length;
const withAddTag = withMutation(
gql`
mutation AddTag($id: ID!, $asset_id: ID!, $name: String!) {
@@ -163,7 +160,7 @@ export default (tag) => (WrappedComponent) => {
render() {
const {comment} = this.props;
const alreadyTagged = isTagged(comment.tags);
const alreadyTagged = isTagged(comment.tags, Tag.toUpperCase());
return <WrappedComponent
user={this.props.user}
+1 -1
View File
@@ -1 +1 @@
export {insertCommentsSorted} from 'coral-framework/utils';
export {isTagged, insertCommentsSorted} from 'coral-framework/utils';