resolving all promises at once
This commit is contained in:
parent
6433b6e951
commit
8e9245b37f
2 changed files with 12 additions and 6 deletions
|
|
@ -153,12 +153,18 @@ export default {
|
||||||
await this.mainStore.saveCapabilityQuestionAnswers(questionAnswersArray);
|
await this.mainStore.saveCapabilityQuestionAnswers(questionAnswersArray);
|
||||||
|
|
||||||
// set recalibration properties of parts based on capability question answers
|
// set recalibration properties of parts based on capability question answers
|
||||||
for (let answer of questionAnswersArray) {
|
const promiseResultMap = questionAnswersArray.map((answer, i) => {
|
||||||
|
const partData = this.partsOrQuestionsData.find(x => x.glassLocation === answer.glassLocation);
|
||||||
|
return {
|
||||||
|
resultKey: i,
|
||||||
|
promise: useMainStore().updatePartFromCapabilityQuestionAnswer(partData.parts[0], answer)
|
||||||
|
};
|
||||||
|
});
|
||||||
|
const resultMap = await settleAllPromises(promiseResultMap);
|
||||||
|
questionAnswersArray.forEach((answer, i) => {
|
||||||
const partData = this.partsOrQuestionsData.find((x) => x.glassLocation === answer.glassLocation);
|
const partData = this.partsOrQuestionsData.find((x) => x.glassLocation === answer.glassLocation);
|
||||||
if (partData) {
|
partData.parts[0] = resultMap[i];
|
||||||
partData.parts[0] = await useMainStore().getPartFromCapabilityQuestionAnswer(partData.parts[0], answer);
|
});
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
this.navigateForward(this.partsOrQuestionsData, null);
|
this.navigateForward(this.partsOrQuestionsData, null);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -815,7 +815,7 @@ export const useMainStore = defineStore({
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
async getPartFromCapabilityQuestionAnswer(part, capabilityQuestionAnswersForPart) {
|
async updatePartFromCapabilityQuestionAnswer(part, capabilityQuestionAnswersForPart) {
|
||||||
return (await globalMethods.callHttpClient({
|
return (await globalMethods.callHttpClient({
|
||||||
method: endpoints.GetPartFromCapabilityAnswer.method,
|
method: endpoints.GetPartFromCapabilityAnswer.method,
|
||||||
endpoint: endpoints.GetPartFromCapabilityAnswer.url,
|
endpoint: endpoints.GetPartFromCapabilityAnswer.url,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue