Avoiding refetching

This commit is contained in:
okbel
2018-04-04 07:25:47 -03:00
parent de6f325204
commit 06f8926964
3 changed files with 9 additions and 16 deletions
@@ -28,16 +28,6 @@ import UserInfoTooltip from './UserInfoTooltip';
import t from 'coral-framework/services/i18n';
class UserDetail extends React.Component {
rejectThenReload = async info => {
await this.props.rejectComment(info);
this.props.data.refetch();
};
acceptThenReload = async info => {
await this.props.acceptComment(info);
this.props.data.refetch();
};
bulkAcceptThenReload = async () => {
await this.props.bulkAccept();
this.props.data.refetch();
@@ -110,6 +100,8 @@ class UserDetail extends React.Component {
unbanUser,
unsuspendUser,
modal,
acceptComment,
rejectComment,
} = this.props;
// if totalComments is 0, you're dividing by zero
@@ -304,8 +296,8 @@ class UserDetail extends React.Component {
loadMore={loadMore}
toggleSelect={toggleSelect}
viewUserDetail={viewUserDetail}
acceptComment={this.acceptThenReload}
rejectComment={this.rejectThenReload}
acceptComment={acceptComment}
rejectComment={rejectComment}
selectedCommentIds={selectedCommentIds}
toggleSelectAll={toggleSelectAll}
bulkAcceptThenReload={this.bulkAcceptThenReload}
@@ -322,8 +314,8 @@ class UserDetail extends React.Component {
loadMore={loadMore}
toggleSelect={toggleSelect}
viewUserDetail={viewUserDetail}
acceptComment={this.acceptThenReload}
rejectComment={this.rejectThenReload}
acceptComment={acceptComment}
rejectComment={rejectComment}
selectedCommentIds={selectedCommentIds}
toggleSelectAll={toggleSelectAll}
bulkAcceptThenReload={this.bulkAcceptThenReload}
@@ -109,6 +109,7 @@ class UserDetailContainer extends React.Component {
componentWillReceiveProps(next) {
if (this.props.userId === null && next.userId) {
next.data.refetch();
console.log('fetching');
}
}
@@ -148,6 +149,7 @@ UserDetailContainer.propTypes = {
selectedCommentIds: PropTypes.array,
unbanUser: PropTypes.func.isRequired,
unsuspendUser: PropTypes.func.isRequired,
userId: PropTypes.string,
};
const LOAD_MORE_QUERY = gql`
@@ -245,7 +247,6 @@ export const withUserDetailQuery = withQuery(
options: ({ userId, statuses }) => {
return {
variables: { author_id: userId, statuses },
fetchPolicy: 'network-only',
};
},
skip: ownProps => !ownProps.userId,
+1 -1
View File
@@ -180,7 +180,7 @@ export const withSetCommentStatus = withMutation(
const fragmentId = `Comment_${commentId}`;
const data = proxy.readFragment({ fragment, id: fragmentId });
console.log('data', data);
data.status = status;
data.status_history = data.status_history
? data.status_history