From d6f7358f819c399b71b5fefa416beaa2441fc23c Mon Sep 17 00:00:00 2001 From: David Baker Date: Wed, 10 Aug 2016 18:50:56 +0100 Subject: [PATCH] Make completionStates an object So that we can sensibly track the number completed by taking the length of it. --- src/components/views/dialogs/MultiInviteDialog.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/components/views/dialogs/MultiInviteDialog.js b/src/components/views/dialogs/MultiInviteDialog.js index 3ed0bb89c9..1e8b8bc96a 100644 --- a/src/components/views/dialogs/MultiInviteDialog.js +++ b/src/components/views/dialogs/MultiInviteDialog.js @@ -28,8 +28,8 @@ export default class MultiInviteDialog extends React.Component { this.state = { busy: false, - completionStates: [], // State of each address (invited or error) - errorTexts: [], // Textual error per address + completionStates: {}, // State of each address (invited or error) + errorTexts: {}, // Textual error per address done: false, }; for (let i = 0; i < this.props.inputs.length; ++i) { @@ -114,16 +114,19 @@ export default class MultiInviteDialog extends React.Component { } _getProgressIndicator() { - const numErrors = this.state.completionStates.filter((s) => { - return s == 'error'; - }).length; + let numErrors = 0; + for (const k of Object.keys(this.state.completionStates)) { + if (this.state.completionStates[k] == 'error') { + ++numErrors; + } + } let errorText; if (numErrors > 0) { const plural = numErrors > 1 ? 's' : ''; errorText = ({numErrors} error{plural}) } return - {this.state.completionStates.length} / {this.props.inputs.length} {errorText} + {Object.keys(this.state.completionStates).length} / {this.props.inputs.length} {errorText} ; }