From f596a7a8aa17fb8c72180965b0f43afa6ae75fb0 Mon Sep 17 00:00:00 2001 From: Matthew Grove Date: Sun, 12 Sep 2021 22:55:14 +0100 Subject: [PATCH] [FIX] data format when creating progress record Was using dictionary as code duplicated from home page. Only one value is ever present so dictionary not required. --- src/SetPage.js | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/SetPage.js b/src/SetPage.js index 93d72d6..8a0bd0c 100644 --- a/src/SetPage.js +++ b/src/SetPage.js @@ -264,16 +264,12 @@ export default withRouter(class SetPage extends React.Component { this.setState({ loading: true, }) - const setIds = Object.keys(this.state.selections) - .filter(x => this.state.selections[x]); - const totalTestQuestions = (await Promise.all(setIds.map((setId) => - this.state.db.collection("sets") - .doc(setId) - .collection("vocab") - .get() - .then(querySnapshot => querySnapshot.docs.length) - ))).reduce((a, b) => a + b); + const totalTestQuestions = await this.state.db.collection("sets") + .doc(this.props.match.params.setId) + .collection("vocab") + .get() + .then(querySnapshot => querySnapshot.docs.length); this.setState({ showTestStart: false, @@ -488,7 +484,7 @@ export default withRouter(class SetPage extends React.Component { onSliderChange={this.changeSliderValue} switchLanguage={this.state.switchLanguage} handleSwitchLanguageChange={this.handleSwitchLanguageChange} - loading={this.state.loading} + loading={this.state.loading} /> } {