mirror of
https://github.com/wassname/talk.git
synced 2026-09-09 11:38:08 +08:00
replaced eslint:recommended with prettier
This commit is contained in:
@@ -1,13 +1,9 @@
|
||||
import {gql} from 'react-apollo';
|
||||
import { gql } from 'react-apollo';
|
||||
import Comment from '../components/Comment';
|
||||
import {withFragments} from 'plugin-api/beta/client/hocs';
|
||||
import {getSlotFragmentSpreads} from 'plugin-api/beta/client/utils';
|
||||
import { withFragments } from 'plugin-api/beta/client/hocs';
|
||||
import { getSlotFragmentSpreads } from 'plugin-api/beta/client/utils';
|
||||
|
||||
const slots = [
|
||||
'commentReactions',
|
||||
'commentAuthorName',
|
||||
'commentTimestamp',
|
||||
];
|
||||
const slots = ['commentReactions', 'commentAuthorName', 'commentTimestamp'];
|
||||
|
||||
export default withFragments({
|
||||
root: gql`
|
||||
@@ -39,5 +35,5 @@ export default withFragments({
|
||||
}
|
||||
${getSlotFragmentSpreads(slots, 'comment')}
|
||||
}
|
||||
`
|
||||
`,
|
||||
})(Comment);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import FeaturedButton from '../components/FeaturedButton';
|
||||
import {withTags} from 'plugin-api/beta/client/hocs';
|
||||
import { withTags } from 'plugin-api/beta/client/hocs';
|
||||
|
||||
export default withTags('featured')(FeaturedButton);
|
||||
|
||||
@@ -1,23 +1,26 @@
|
||||
import {compose} from 'react-apollo';
|
||||
import {bindActionCreators} from 'redux';
|
||||
import { compose } from 'react-apollo';
|
||||
import { bindActionCreators } from 'redux';
|
||||
import FeaturedDialog from '../components/FeaturedDialog';
|
||||
import {withTags, connect} from 'plugin-api/beta/client/hocs';
|
||||
import {closeFeaturedDialog} from '../actions';
|
||||
import { withTags, connect } from 'plugin-api/beta/client/hocs';
|
||||
import { closeFeaturedDialog } from '../actions';
|
||||
|
||||
const mapStateToProps = ({talkPluginFeaturedComments: state}) => ({
|
||||
const mapStateToProps = ({ talkPluginFeaturedComments: state }) => ({
|
||||
showFeaturedDialog: state.showFeaturedDialog,
|
||||
comment: state.comment,
|
||||
asset: state.asset,
|
||||
});
|
||||
|
||||
const mapDispatchToProps = (dispatch) =>
|
||||
bindActionCreators({
|
||||
closeFeaturedDialog,
|
||||
}, dispatch);
|
||||
const mapDispatchToProps = dispatch =>
|
||||
bindActionCreators(
|
||||
{
|
||||
closeFeaturedDialog,
|
||||
},
|
||||
dispatch
|
||||
);
|
||||
|
||||
const enhance = compose(
|
||||
connect(mapStateToProps, mapDispatchToProps),
|
||||
withTags('featured'),
|
||||
withTags('featured')
|
||||
);
|
||||
|
||||
export default enhance(FeaturedDialog);
|
||||
|
||||
@@ -1,17 +1,20 @@
|
||||
import {compose} from 'react-apollo';
|
||||
import {bindActionCreators} from 'redux';
|
||||
import { compose } from 'react-apollo';
|
||||
import { bindActionCreators } from 'redux';
|
||||
import ModActionButton from '../components/ModActionButton';
|
||||
import {withTags, connect} from 'plugin-api/beta/client/hocs';
|
||||
import {closeMenu} from 'plugins/talk-plugin-moderation-actions/client/actions';
|
||||
import { withTags, connect } from 'plugin-api/beta/client/hocs';
|
||||
import { closeMenu } from 'plugins/talk-plugin-moderation-actions/client/actions';
|
||||
|
||||
const mapDispatchToProps = (dispatch) =>
|
||||
bindActionCreators({
|
||||
closeMenu,
|
||||
}, dispatch);
|
||||
const mapDispatchToProps = dispatch =>
|
||||
bindActionCreators(
|
||||
{
|
||||
closeMenu,
|
||||
},
|
||||
dispatch
|
||||
);
|
||||
|
||||
const enhance = compose(
|
||||
withTags('featured'),
|
||||
connect(null, mapDispatchToProps),
|
||||
connect(null, mapDispatchToProps)
|
||||
);
|
||||
|
||||
export default enhance(ModActionButton);
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import React from 'react';
|
||||
import {gql} from 'react-apollo';
|
||||
import {connect} from 'react-redux';
|
||||
import { gql } from 'react-apollo';
|
||||
import { connect } from 'react-redux';
|
||||
import Comment from 'coral-admin/src/routes/Moderation/containers/Comment';
|
||||
import {getDefinitionName} from 'coral-framework/utils';
|
||||
import { getDefinitionName } from 'coral-framework/utils';
|
||||
import truncate from 'lodash/truncate';
|
||||
import t from 'coral-framework/services/i18n';
|
||||
|
||||
function prepareNotificationText(text) {
|
||||
return truncate(text, {length: 50}).replace('\n', ' ');
|
||||
return truncate(text, { length: 50 }).replace('\n', ' ');
|
||||
}
|
||||
|
||||
class ModSubscription extends React.Component {
|
||||
@@ -20,14 +20,18 @@ class ModSubscription extends React.Component {
|
||||
variables: {
|
||||
assetId: this.props.data.variables.asset_id,
|
||||
},
|
||||
updateQuery: (prev, {subscriptionData: {data: {commentFeatured: {user, comment}}}}) => {
|
||||
const notifyText = this.props.user.id === user.id
|
||||
? ''
|
||||
: t(
|
||||
'talk-plugin-featured-comments.notify_featured',
|
||||
user.username,
|
||||
prepareNotificationText(comment.body),
|
||||
);
|
||||
updateQuery: (
|
||||
prev,
|
||||
{ subscriptionData: { data: { commentFeatured: { user, comment } } } }
|
||||
) => {
|
||||
const notifyText =
|
||||
this.props.user.id === user.id
|
||||
? ''
|
||||
: t(
|
||||
'talk-plugin-featured-comments.notify_featured',
|
||||
user.username,
|
||||
prepareNotificationText(comment.body)
|
||||
);
|
||||
return this.props.handleCommentChange(prev, comment, notifyText);
|
||||
},
|
||||
},
|
||||
@@ -36,23 +40,33 @@ class ModSubscription extends React.Component {
|
||||
variables: {
|
||||
assetId: this.props.data.variables.asset_id,
|
||||
},
|
||||
updateQuery: (prev, {subscriptionData: {data: {commentUnfeatured: {user, comment}}}}) => {
|
||||
const notify = this.props.user.id === user.id
|
||||
? ''
|
||||
: t(
|
||||
'talk-plugin-featured-comments.notify_unfeatured',
|
||||
user.username,
|
||||
prepareNotificationText(comment.body),
|
||||
);
|
||||
updateQuery: (
|
||||
prev,
|
||||
{
|
||||
subscriptionData: {
|
||||
data: { commentUnfeatured: { user, comment } },
|
||||
},
|
||||
}
|
||||
) => {
|
||||
const notify =
|
||||
this.props.user.id === user.id
|
||||
? ''
|
||||
: t(
|
||||
'talk-plugin-featured-comments.notify_unfeatured',
|
||||
user.username,
|
||||
prepareNotificationText(comment.body)
|
||||
);
|
||||
return this.props.handleCommentChange(prev, comment, notify);
|
||||
}
|
||||
},
|
||||
},
|
||||
];
|
||||
this.subscriptions = configs.map((config) => this.props.data.subscribeToMore(config));
|
||||
this.subscriptions = configs.map(config =>
|
||||
this.props.data.subscribeToMore(config)
|
||||
);
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
this.subscriptions.forEach((unsubscribe) => unsubscribe());
|
||||
this.subscriptions.forEach(unsubscribe => unsubscribe());
|
||||
}
|
||||
|
||||
render() {
|
||||
@@ -98,7 +112,7 @@ const COMMENT_UNFEATURED_SUBSCRIPTION = gql`
|
||||
${Comment.fragments.comment}
|
||||
`;
|
||||
|
||||
const mapStateToProps = (state) => ({
|
||||
const mapStateToProps = state => ({
|
||||
user: state.auth.user,
|
||||
});
|
||||
|
||||
|
||||
@@ -1,15 +1,18 @@
|
||||
import ModTag from '../components/ModTag';
|
||||
import {withTags, connect} from 'plugin-api/beta/client/hocs';
|
||||
import {gql, compose} from 'react-apollo';
|
||||
import {bindActionCreators} from 'redux';
|
||||
import {openFeaturedDialog} from '../actions';
|
||||
import {notify} from 'plugin-api/beta/client/actions/notification';
|
||||
import { withTags, connect } from 'plugin-api/beta/client/hocs';
|
||||
import { gql, compose } from 'react-apollo';
|
||||
import { bindActionCreators } from 'redux';
|
||||
import { openFeaturedDialog } from '../actions';
|
||||
import { notify } from 'plugin-api/beta/client/actions/notification';
|
||||
|
||||
const mapDispatchToProps = (dispatch) =>
|
||||
bindActionCreators({
|
||||
notify,
|
||||
openFeaturedDialog,
|
||||
}, dispatch);
|
||||
const mapDispatchToProps = dispatch =>
|
||||
bindActionCreators(
|
||||
{
|
||||
notify,
|
||||
openFeaturedDialog,
|
||||
},
|
||||
dispatch
|
||||
);
|
||||
|
||||
const fragments = {
|
||||
comment: gql`
|
||||
@@ -18,11 +21,11 @@ const fragments = {
|
||||
username
|
||||
}
|
||||
}
|
||||
`
|
||||
`,
|
||||
};
|
||||
const enhance = compose(
|
||||
withTags('featured', {fragments}),
|
||||
connect(null, mapDispatchToProps),
|
||||
withTags('featured', { fragments }),
|
||||
connect(null, mapDispatchToProps)
|
||||
);
|
||||
|
||||
export default enhance(ModTag);
|
||||
|
||||
@@ -1,17 +1,21 @@
|
||||
import Tab from '../components/Tab';
|
||||
import {withFragments, excludeIf} from 'plugin-api/beta/client/hocs';
|
||||
import {compose, gql} from 'react-apollo';
|
||||
import {withProps} from 'recompose';
|
||||
import { withFragments, excludeIf } from 'plugin-api/beta/client/hocs';
|
||||
import { compose, gql } from 'react-apollo';
|
||||
import { withProps } from 'recompose';
|
||||
|
||||
const enhance = compose(
|
||||
withFragments({
|
||||
asset: gql`
|
||||
fragment TalkFeaturedComments_Tab_asset on Asset {
|
||||
featuredCommentsCount: totalCommentCount(tags: ["FEATURED"]) @skip(if: $hasComment)
|
||||
}`,
|
||||
featuredCommentsCount: totalCommentCount(tags: ["FEATURED"])
|
||||
@skip(if: $hasComment)
|
||||
}
|
||||
`,
|
||||
}),
|
||||
excludeIf((props) => props.asset.featuredCommentsCount === 0),
|
||||
withProps((props) => ({featuredCommentsCount: props.asset.featuredCommentsCount})),
|
||||
excludeIf(props => props.asset.featuredCommentsCount === 0),
|
||||
withProps(props => ({
|
||||
featuredCommentsCount: props.asset.featuredCommentsCount,
|
||||
}))
|
||||
);
|
||||
|
||||
export default enhance(Tab);
|
||||
|
||||
@@ -1,16 +1,18 @@
|
||||
import React from 'react';
|
||||
import {bindActionCreators} from 'redux';
|
||||
import {compose, gql} from 'react-apollo';
|
||||
import { bindActionCreators } from 'redux';
|
||||
import { compose, gql } from 'react-apollo';
|
||||
import TabPane from '../components/TabPane';
|
||||
import {withFragments, connect} from 'plugin-api/beta/client/hocs';
|
||||
import { withFragments, connect } from 'plugin-api/beta/client/hocs';
|
||||
import Comment from '../containers/Comment';
|
||||
import {notify} from 'plugin-api/beta/client/actions/notification';
|
||||
import {viewComment} from 'coral-embed-stream/src/actions/stream';
|
||||
import {appendNewNodes, getDefinitionName} from 'plugin-api/beta/client/utils';
|
||||
import { notify } from 'plugin-api/beta/client/actions/notification';
|
||||
import { viewComment } from 'coral-embed-stream/src/actions/stream';
|
||||
import {
|
||||
appendNewNodes,
|
||||
getDefinitionName,
|
||||
} from 'plugin-api/beta/client/utils';
|
||||
import update from 'immutability-helper';
|
||||
|
||||
class TabPaneContainer extends React.Component {
|
||||
|
||||
loadMore = () => {
|
||||
return this.props.data.fetchMore({
|
||||
query: LOAD_MORE_QUERY,
|
||||
@@ -22,17 +24,17 @@ class TabPaneContainer extends React.Component {
|
||||
sortBy: this.props.data.variables.sortBy,
|
||||
excludeIgnored: this.props.data.variables.excludeIgnored,
|
||||
},
|
||||
updateQuery: (previous, {fetchMoreResult:{comments}}) => {
|
||||
updateQuery: (previous, { fetchMoreResult: { comments } }) => {
|
||||
const updated = update(previous, {
|
||||
asset: {
|
||||
featuredComments: {
|
||||
nodes: {
|
||||
$apply: (nodes) => appendNewNodes(nodes, comments.nodes),
|
||||
$apply: nodes => appendNewNodes(nodes, comments.nodes),
|
||||
},
|
||||
hasNextPage: {$set: comments.hasNextPage},
|
||||
endCursor: {$set: comments.endCursor},
|
||||
hasNextPage: { $set: comments.hasNextPage },
|
||||
endCursor: { $set: comments.endCursor },
|
||||
},
|
||||
}
|
||||
},
|
||||
});
|
||||
return updated;
|
||||
},
|
||||
@@ -40,10 +42,7 @@ class TabPaneContainer extends React.Component {
|
||||
};
|
||||
|
||||
render() {
|
||||
return <TabPane
|
||||
{...this.props}
|
||||
loadMore={this.loadMore}
|
||||
/>;
|
||||
return <TabPane {...this.props} loadMore={this.loadMore} />;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,11 +77,14 @@ const LOAD_MORE_QUERY = gql`
|
||||
${Comment.fragments.comment}
|
||||
`;
|
||||
|
||||
const mapDispatchToProps = (dispatch) =>
|
||||
bindActionCreators({
|
||||
viewComment,
|
||||
notify,
|
||||
}, dispatch);
|
||||
const mapDispatchToProps = dispatch =>
|
||||
bindActionCreators(
|
||||
{
|
||||
viewComment,
|
||||
notify,
|
||||
},
|
||||
dispatch
|
||||
);
|
||||
|
||||
const enhance = compose(
|
||||
connect(null, mapDispatchToProps),
|
||||
@@ -118,7 +120,7 @@ const enhance = compose(
|
||||
${Comment.fragments.comment}
|
||||
${Comment.fragments.asset}
|
||||
`,
|
||||
}),
|
||||
})
|
||||
);
|
||||
|
||||
export default enhance(TabPaneContainer);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import {compose, gql} from 'react-apollo';
|
||||
import { compose, gql } from 'react-apollo';
|
||||
import Tag from '../components/Tag';
|
||||
import {isTagged} from 'plugin-api/beta/client/utils';
|
||||
import {withFragments, excludeIf} from 'plugin-api/beta/client/hocs';
|
||||
import { isTagged } from 'plugin-api/beta/client/utils';
|
||||
import { withFragments, excludeIf } from 'plugin-api/beta/client/hocs';
|
||||
|
||||
export default compose(
|
||||
withFragments({
|
||||
@@ -13,6 +13,7 @@ export default compose(
|
||||
}
|
||||
}
|
||||
}
|
||||
`}),
|
||||
excludeIf((props) => !isTagged(props.comment.tags, 'FEATURED'))
|
||||
`,
|
||||
}),
|
||||
excludeIf(props => !isTagged(props.comment.tags, 'FEATURED'))
|
||||
)(Tag);
|
||||
|
||||
Reference in New Issue
Block a user