Skip to content

Commit 0f1920b

Browse files
authored
fix: Class object counters in sidebar not updating (#2950)
1 parent cbd712f commit 0f1920b

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

src/dashboard/Data/Browser/Browser.react.js

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -982,17 +982,27 @@ class Browser extends DashboardView {
982982
}
983983

984984
async handleFetchedSchema() {
985-
const counts = this.state.counts;
986985
if (this.state.computingClassCounts === false) {
987986
this.setState({ computingClassCounts: true });
987+
988+
const promises = [];
988989
for (const parseClass of this.props.schema.data.get('classes')) {
989990
const [className] = parseClass;
990-
counts[className] = await this.context.getClassCount(className);
991+
const promise = this.context.getClassCount(className).then(count => {
992+
this.setState(prevState => ({
993+
counts: {
994+
...prevState.counts,
995+
[className]: count
996+
}
997+
}));
998+
});
999+
promises.push(promise);
9911000
}
9921001

1002+
await Promise.all(promises);
1003+
9931004
this.setState({
9941005
clp: this.props.schema.data.get('CLPs').toJS(),
995-
counts,
9961006
computingClassCounts: false,
9971007
});
9981008
}
@@ -2192,7 +2202,8 @@ class Browser extends DashboardView {
21922202
classes.forEach((value, key) => {
21932203
let count = this.state.counts[key];
21942204
if (count === undefined) {
2195-
count = '';
2205+
// Show loading indicator while counts are being computed, empty string if computation is done
2206+
count = this.state.computingClassCounts ? '...' : '';
21962207
} else if (count >= 1000) {
21972208
count = prettyNumber(count);
21982209
}

0 commit comments

Comments
 (0)