From 1f489ff0e5d08fbbd6e0bcf653482a2605d7781f Mon Sep 17 00:00:00 2001 From: Chi Vinh Le Date: Wed, 30 Aug 2017 22:30:53 +0700 Subject: [PATCH] Always refetch when switching to FlaggedAccounts --- .../Community/containers/FlaggedAccounts.js | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/client/coral-admin/src/routes/Community/containers/FlaggedAccounts.js b/client/coral-admin/src/routes/Community/containers/FlaggedAccounts.js index d4dca76f6..cfa66f732 100644 --- a/client/coral-admin/src/routes/Community/containers/FlaggedAccounts.js +++ b/client/coral-admin/src/routes/Community/containers/FlaggedAccounts.js @@ -19,6 +19,26 @@ import FlaggedUser from '../containers/FlaggedUser'; class FlaggedAccountsContainer extends Component { + state = {refetching: false}; + + constructor(props) { + super(props); + } + + componentWillMount() { + if (!this.props.data.loading) { + this.setState({refetching: true}); + this.props.data.refetch() + .then(() => { + this.setState({refetching: false}); + }) + .catch((err) => { + this.setState({refetching: false}); + throw err; + }); + } + } + approveUser = ({userId}) => { return this.props.setUserStatus({userId, status: 'APPROVED'}); } @@ -50,7 +70,7 @@ class FlaggedAccountsContainer extends Component { return
{this.props.data.error.message}
; } - if (this.props.data.loading) { + if (this.props.data.loading || this.state.refetching) { return
; } return (