Merge pull request #349 from status-im/feat/poll-balance-arbitrator
feat: poll balance for arbitrator license
This commit is contained in:
commit
a0445ec963
|
@ -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 = () => {
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -179,7 +179,10 @@ exports[`Offers should render correctly 1`] = `
|
|||
<dt>
|
||||
Arbitrator
|
||||
</dt>
|
||||
<dd />
|
||||
<dd>
|
||||
(
|
||||
)
|
||||
</dd>
|
||||
</dl>
|
||||
</Row>
|
||||
</CardBody>
|
||||
|
|
Loading…
Reference in New Issue