diff --git a/src/App.jsx b/src/App.jsx index 4a9ca6e..6c92fd2 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -26,6 +26,7 @@ export default class App extends Component { this.state = { runningTaskCount: 0, + isFetching: false, repoDescription: "", }; @@ -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() { diff --git a/src/SourcesTable.jsx b/src/SourcesTable.jsx index 4369379..29474ff 100644 --- a/src/SourcesTable.jsx +++ b/src/SourcesTable.jsx @@ -23,6 +23,7 @@ export class SourcesTable extends Component { this.state = { sources: [], isLoading: false, + isFetching: false, isRefreshing: false, error: null, @@ -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) {