Skip to content

Commit

Permalink
Merge pull request #4261 from brave-intl/feat/poll-for-prices
Browse files Browse the repository at this point in the history
update prices every 5 minutes
  • Loading branch information
jlbyrne authored Nov 1, 2023
2 parents c612d57 + 70ad562 commit 11951c3
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions app/javascript/views/publicChannelPage/CryptoPaymentWidget.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,21 @@ class CryptoPaymentWidget extends React.Component {

componentDidMount() {
this.loadData();

// Set up a setInterval to fetch new price data every 5 minutes (300,000 milliseconds)
this.intervalId = setInterval(this.backgroundLoadData.bind(this), 300000);
}

componentWillUnmount() {
clearInterval(this.intervalId);
}

backgroundLoadData() {
axios.get(routes.publishers.publicChannelPage.getRatios).then((response) => {
const newState = { ...this.state }
newState.ratios = response.data;
this.setState({ ...newState });
});
}

loadData = () => {
Expand Down

0 comments on commit 11951c3

Please sign in to comment.