Always refetch when switching to FlaggedAccounts

This commit is contained in:
Chi Vinh Le
2017-08-30 22:30:53 +07:00
parent f582cc2534
commit 1f489ff0e5
@@ -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 <div>{this.props.data.error.message}</div>;
}
if (this.props.data.loading) {
if (this.props.data.loading || this.state.refetching) {
return <div><Spinner/></div>;
}
return (