Make completionStates an object
So that we can sensibly track the number completed by taking the length of it.
This commit is contained in:
parent
fa498eb8c6
commit
d6f7358f81
1 changed files with 9 additions and 6 deletions
|
@ -28,8 +28,8 @@ export default class MultiInviteDialog extends React.Component {
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
busy: false,
|
busy: false,
|
||||||
completionStates: [], // State of each address (invited or error)
|
completionStates: {}, // State of each address (invited or error)
|
||||||
errorTexts: [], // Textual error per address
|
errorTexts: {}, // Textual error per address
|
||||||
done: false,
|
done: false,
|
||||||
};
|
};
|
||||||
for (let i = 0; i < this.props.inputs.length; ++i) {
|
for (let i = 0; i < this.props.inputs.length; ++i) {
|
||||||
|
@ -114,16 +114,19 @@ export default class MultiInviteDialog extends React.Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
_getProgressIndicator() {
|
_getProgressIndicator() {
|
||||||
const numErrors = this.state.completionStates.filter((s) => {
|
let numErrors = 0;
|
||||||
return s == 'error';
|
for (const k of Object.keys(this.state.completionStates)) {
|
||||||
}).length;
|
if (this.state.completionStates[k] == 'error') {
|
||||||
|
++numErrors;
|
||||||
|
}
|
||||||
|
}
|
||||||
let errorText;
|
let errorText;
|
||||||
if (numErrors > 0) {
|
if (numErrors > 0) {
|
||||||
const plural = numErrors > 1 ? 's' : '';
|
const plural = numErrors > 1 ? 's' : '';
|
||||||
errorText = <span className="error">({numErrors} error{plural})</span>
|
errorText = <span className="error">({numErrors} error{plural})</span>
|
||||||
}
|
}
|
||||||
return <span>
|
return <span>
|
||||||
{this.state.completionStates.length} / {this.props.inputs.length} {errorText}
|
{Object.keys(this.state.completionStates).length} / {this.props.inputs.length} {errorText}
|
||||||
</span>;
|
</span>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue