Merge pull request #349 from status-im/feat/poll-balance-arbitrator

feat: poll balance for arbitrator license
This commit is contained in:
Jonathan Rainville 2019-07-08 09:55:31 -04:00 committed by GitHub
commit a0445ec963
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 39 additions and 6 deletions

View File

@ -27,11 +27,34 @@ class ArbitrationLicense extends Component {
this.props.updateBalance(LICENSE_TOKEN_SYMBOL);
}
checkBalance() {
if (this.props.sntToken && this.props.sntToken.balance) {
if (this.enoughBalance()) {
if (this.pollBalanceInterval) {
clearInterval(this.pollBalanceInterval);
}
} else {
if (!this.pollBalanceInterval) {
this.pollBalanceInterval = setInterval(() => {
this.props.updateBalance(LICENSE_TOKEN_SYMBOL);
}, 2000);
}
}
}
}
componentDidUpdate() {
if (this.props.isLicenseOwner) {
this.props.loadProfile(this.props.address);
return this.props.history.push('/profile/contact/edit');
}
this.checkBalance();
}
componentWillUnmount() {
if (this.pollBalanceInterval) {
clearInterval(this.pollBalanceInterval);
}
}
buyLicense = () => {

View File

@ -49,6 +49,12 @@ class License extends Component {
this.checkBalance();
}
componentWillUnmount() {
if (this.pollBalanceInterval) {
clearInterval(this.pollBalanceInterval);
}
}
buyLicense = () => {
this.setState({isBuying: true});
this.props.buyLicense();

View File

@ -4,7 +4,7 @@ import { Row, Card, CardHeader, CardBody, Button} from 'reactstrap';
import { Link } from "react-router-dom";
import { withNamespaces } from 'react-i18next';
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { faArrowRight, faEllipsisV, faExclamationTriangle } from "@fortawesome/free-solid-svg-icons";
import { faArrowRight, faEllipsisV } from "@fortawesome/free-solid-svg-icons";
import ConfirmDialog from "../../../components/ConfirmDialog";
import {CURRENCY_DATA} from "../../../constants/currencies";
import {zeroAddress} from '../../../utils/address';
@ -77,7 +77,7 @@ class Offers extends Component {
{offer.arbitrator === zeroAddress && <dd>
<NoArbitratorWarning arbitrator={offer.arbitrator} />
</dd>}
{offer.arbitrator !== zeroAddress && <dd>{offer.arbitratorData.username} ({offer.arbitrator})</dd> }
{offer.arbitrator !== zeroAddress && <dd>{offer.arbitratorData.username} ({offer.arbitrator})</dd> }
</dl>
</Row>
</CardBody>

View File

@ -15,17 +15,18 @@ describe('Offers', () => {
currency: 'EUR',
paymentMethods: ['Credit Card'],
margin: 1,
marketType: 1
marketType: 1,
arbitratorData: {}
}
]
} />);
expect(component).toMatchSnapshot();
});
it('should render when empty', () => {
const component = shallow(<Offers offers={[]} />);
expect(component).toMatchSnapshot();
});
});

View File

@ -179,7 +179,10 @@ exports[`Offers should render correctly 1`] = `
<dt>
Arbitrator
</dt>
<dd />
<dd>
(
)
</dd>
</dl>
</Row>
</CardBody>