Skip to content

Commit

Permalink
Merge pull request #86 from eco-stake/hide-refresh-errors
Browse files Browse the repository at this point in the history
Hide errors when refreshing in background
  • Loading branch information
tombeynon authored Mar 7, 2022
2 parents 3370715 + daeb1bc commit d4e78d4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
6 changes: 3 additions & 3 deletions src/components/Delegations.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,12 @@ class Delegations extends React.Component {

refreshInterval(){
const interval = setInterval(() => {
this.getRewards()
this.getRewards(true)
}, 15_000)
this.setState({refreshInterval: interval})
}

getRewards() {
getRewards(hideError) {
this.props.restClient.getRewards(this.props.address, this.props.network.denom)
.then(
(rewards) => {
Expand All @@ -84,7 +84,7 @@ class Delegations extends React.Component {
if([404, 500].includes(error.response && error.response.status)){
this.setState({ rewards: {} });
}else{
this.setState({ error: 'Failed to get rewards. Please refresh' });
if(!hideError) this.setState({ error: 'Failed to get rewards. Please refresh' });
}
}
)
Expand Down
11 changes: 5 additions & 6 deletions src/components/Wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class Wallet extends React.Component {

refreshInterval(){
const interval = setInterval(() => {
this.getDelegations()
this.getDelegations(true)
}, 30_000)
this.setState({refreshInterval: interval})
}
Expand All @@ -51,7 +51,7 @@ class Wallet extends React.Component {
setTimeout(() => this.getDelegations(), 3_000)
}

async getDelegations() {
async getDelegations(hideError) {
this.props.restClient.getDelegations(this.props.address)
.then(
(delegations) => {
Expand All @@ -61,14 +61,13 @@ class Wallet extends React.Component {
});
},
(error) => {
this.setState({ isLoaded: true })
if([404, 500].includes(error.response && error.response.status)){
this.setState({
isLoaded: true,
delegations: {},
delegations: {}
});
}else{
}else if(!hideError){
this.setState({
isLoaded: true,
error: 'Failed to load delegations. Please refresh.'
});
}
Expand Down

0 comments on commit d4e78d4

Please sign in to comment.