diff --git a/src/App.jsx b/src/App.jsx index fcf7551..cf3410d 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -64,14 +64,13 @@ export default class App extends Component { } fetchTaskSummary() { - if( ! this.state.isFetching ) - { + if (!this.state.isFetching) { this.setState({ isFetching: true }); - axios.get('/api/v1/tasks-summary').then(result => { - this.setState({ isFetching: false, runningTaskCount: result.data["RUNNING"] || 0 }); - }).catch(error => { - this.setState({ isFetching: false, runningTaskCount: -1 }); - }); + axios.get('/api/v1/tasks-summary').then(result => { + this.setState({ isFetching: false, runningTaskCount: result.data["RUNNING"] || 0 }); + }).catch(error => { + this.setState({ isFetching: false, runningTaskCount: -1 }); + }); } } diff --git a/src/SourcesTable.jsx b/src/SourcesTable.jsx index 6aefb10..db3ebe0 100644 --- a/src/SourcesTable.jsx +++ b/src/SourcesTable.jsx @@ -43,7 +43,8 @@ export class SourcesTable extends Component { } componentDidMount() { - this.setState({ isLoading: true }); + const { defaultSnapshotViewAll } = this.context; + this.setState({ isLoading: true, selectedOwner: defaultSnapshotViewAll ? allSnapshots : localSnapshots }); this.fetchSourcesWithoutSpinner(); this.interval = window.setInterval(this.fetchSourcesWithoutSpinner, 3000); } @@ -53,7 +54,7 @@ export class SourcesTable extends Component { } fetchSourcesWithoutSpinner() { - if( ! this.state.isFetching ){ + if (!this.state.isFetching) { this.setState({ isFetching: true, }); @@ -78,14 +79,12 @@ export class SourcesTable extends Component { } } - selectOwner(h) { + selectOwner(owner) { const { setDefaultSnapshotViewAll } = this.context; - this.setState({ - selectedOwner: h, - }); - if (h === localSnapshots) { + this.setState({ selectedOwner: owner }); + if (owner === localSnapshots) { setDefaultSnapshotViewAll(false); - } else if (h === allSnapshots) { + } else if (owner === allSnapshots) { setDefaultSnapshotViewAll(true); } } @@ -217,16 +216,13 @@ export class SourcesTable extends Component { render() { let { sources, isLoading, error } = this.state; - const { bytesStringBase2, defaultSnapshotViewAll } = this.context + const { bytesStringBase2 } = this.context if (error) { return
{error.message}
; } if (isLoading) { return