mirror of
https://github.com/wassname/talk.git
synced 2026-07-07 16:17:55 +08:00
don't query username count twice
This commit is contained in:
@@ -2,7 +2,7 @@ import React, { Component } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import styles from './Community.css';
|
||||
import People from '../containers/People';
|
||||
import CommunityMenu from './CommunityMenu';
|
||||
import CommunityMenu from '../containers/CommunityMenu';
|
||||
import RejectUsernameDialog from './RejectUsernameDialog';
|
||||
import FlaggedAccounts from '../containers/FlaggedAccounts';
|
||||
|
||||
@@ -35,11 +35,9 @@ class Community extends Component {
|
||||
}
|
||||
|
||||
render() {
|
||||
const { root: { flaggedUsernamesCount } } = this.props;
|
||||
|
||||
return (
|
||||
<div className="talk-admin-community">
|
||||
<CommunityMenu flaggedUsernamesCount={flaggedUsernamesCount} />
|
||||
<CommunityMenu />
|
||||
<div className={styles.container}>{this.renderTab()}</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
import { compose, gql } from 'react-apollo';
|
||||
import { mapProps } from 'recompose';
|
||||
import withQuery from 'coral-framework/hocs/withQuery';
|
||||
import CommunityMenu from '../components/CommunityMenu';
|
||||
import get from 'lodash/get';
|
||||
|
||||
const withData = withQuery(
|
||||
gql`
|
||||
query TalkAdmin_CommunityMenu {
|
||||
flaggedUsernamesCount: userCount(
|
||||
query: {
|
||||
action_type: FLAG
|
||||
state: { status: { username: [SET, CHANGED] } }
|
||||
}
|
||||
)
|
||||
}
|
||||
`,
|
||||
{
|
||||
options: {
|
||||
fetchPolicy: 'cache-only',
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
export default compose(
|
||||
withData,
|
||||
mapProps(ownProps => ({
|
||||
flaggedUsernamesCount: get(ownProps, 'root.flaggedUsernamesCount'),
|
||||
}))
|
||||
)(CommunityMenu);
|
||||
Reference in New Issue
Block a user