Skip to content

Commit

Permalink
feat: improve classes counts
Browse files Browse the repository at this point in the history
  • Loading branch information
christopherbrookes committed Sep 16, 2021
1 parent 689df7c commit 74c0062
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- Add multi-factor authentication to dashboard login. To use one-time password, run `parse-dashboard --createMFA` or `parse-dashboard --createUser`. (Daniel Blyth) [#1624](https://github.com/parse-community/parse-dashboard/pull/1624)

## Improvements
- Sidebar: Class counts are now updated when all counts are returned instead of after each call (Christopher Brookes) [#1802](https://github.com/parse-community/parse-dashboard/pull/1802)
- Update sass to 5.0.0 and make docker image use node:lts-alpine (Corey Baker) [#1792](https://github.com/parse-community/parse-dashboard/pull/1792)
- Docker image use now node 12 version (Christopher Brookes) [#1788](https://github.com/parse-community/parse-dashboard/pull/1788)
- CI now pushes docker images to Docker Hub (Corey Baker) [#1781](https://github.com/parse-community/parse-dashboard/pull/1781)
Expand Down
23 changes: 17 additions & 6 deletions src/dashboard/Data/Browser/Browser.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ class Browser extends DashboardView {

relation: null,
counts: {},
computingClassCounts: false,
filteredCounts: {},
clp: {},
filters: new List(),
Expand Down Expand Up @@ -605,12 +606,22 @@ class Browser extends DashboardView {
});
}

handleFetchedSchema() {
this.props.schema.data.get('classes').forEach((_, className) => {
this.context.currentApp.getClassCount(className)
.then(count => this.setState({ counts: { [className]: count, ...this.state.counts } }));
})
this.setState({clp: this.props.schema.data.get('CLPs').toJS()});
async handleFetchedSchema() {
const counts = this.state.counts;
if (this.state.computingClassCounts === false) {
this.setState({ computingClassCounts: true });
for (const parseClass of this.props.schema.data.get('classes')) {
const [className] = parseClass;
counts[className] = await this.context.currentApp.getClassCount(className);
}

this.setState({
clp: this.props.schema.data.get('CLPs').toJS(),
counts,
...this.state.counts,
computingClassCounts: false
});
}
}

async refresh() {
Expand Down

0 comments on commit 74c0062

Please sign in to comment.