Skip to content

Commit

Permalink
do not allow overlapping update requests from setInterval (#162)
Browse files Browse the repository at this point in the history
  • Loading branch information
riedel committed Jun 5, 2023
1 parent 6a16981 commit f827689
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 16 deletions.
9 changes: 7 additions & 2 deletions src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export default class App extends Component {

this.state = {
runningTaskCount: 0,
isFetching: false,
repoDescription: "",
};

Expand Down Expand Up @@ -65,11 +66,15 @@ export default class App extends Component {
}

fetchTaskSummary() {
if( ! this.state.isFetching )
{
this.setState({ isFetching: true });
axios.get('/api/v1/tasks-summary').then(result => {
this.setState({ runningTaskCount: result.data["RUNNING"] || 0 });
this.setState({ isFetching: false, runningTaskCount: result.data["RUNNING"] || 0 });
}).catch(error => {
this.setState({ runningTaskCount: -1 });
this.setState({ isFetching: false, runningTaskCount: -1 });
});
}
}

componentWillUnmount() {
Expand Down
36 changes: 22 additions & 14 deletions src/SourcesTable.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export class SourcesTable extends Component {
this.state = {
sources: [],
isLoading: false,
isFetching: false,
isRefreshing: false,
error: null,

Expand Down Expand Up @@ -51,22 +52,29 @@ export class SourcesTable extends Component {
}

fetchSourcesWithoutSpinner() {
axios.get('/api/v1/sources').then(result => {
if( ! this.state.isFetching ){
this.setState({
localSourceName: result.data.localUsername + "@" + result.data.localHost,
multiUser: result.data.multiUser,
sources: result.data.sources,
isLoading: false,
isRefreshing: false,
isFetching: true,
});
}).catch(error => {
redirectIfNotConnected(error);
this.setState({
error,
isRefreshing: false,
isLoading: false,
});
});
axios.get('/api/v1/sources').then(result => {
this.setState({
localSourceName: result.data.localUsername + "@" + result.data.localHost,
multiUser: result.data.multiUser,
sources: result.data.sources,
isLoading: false,
isFetching: false,
isRefreshing: false,
});
}).catch(error => {
redirectIfNotConnected(error);
this.setState({
error,
isRefreshing: false,
isFetching: false,
isLoading: false,
});
})
}
}

selectOwner(h) {
Expand Down

0 comments on commit f827689

Please sign in to comment.