Adds subscriber plugin

This commit is contained in:
Belen Curcio
2017-10-02 01:06:08 -03:00
parent 43cb0efe7e
commit 7aaad6ccd9
12 changed files with 136 additions and 0 deletions
@@ -0,0 +1,24 @@
import React from 'react';
import SubscriberBadge from '../components/SubscriberBadge';
import {compose, gql} from 'react-apollo';
import {withFragments, excludeIf} from 'plugin-api/beta/client/hocs';
const isSubscriber = (tags = []) => tags.some((t) => t.tag.name === 'SUBSCRIBER');
const enhance = compose(
withFragments({
comment: gql`
fragment TalkSubscriberBadge_SubscriberBadge_comment on Comment {
user {
tags {
tag {
name
}
}
}
}`
}),
excludeIf(({comment}) => !isSubscriber(comment.user.tags))
);
export default enhance(SubscriberBadge);