Continue button is disabled when uploading a recovery key file (#29695)
* Wait for setState to complete before validating recovery key * Linter fix * Pass in recovery key to validateRecoveryKey function
This commit is contained in:
@@ -86,11 +86,11 @@ export default class AccessSecretStorageDialog extends React.PureComponent<IProp
|
|||||||
};
|
};
|
||||||
|
|
||||||
private validateRecoveryKeyOnChange = debounce(async (): Promise<void> => {
|
private validateRecoveryKeyOnChange = debounce(async (): Promise<void> => {
|
||||||
await this.validateRecoveryKey();
|
await this.validateRecoveryKey(this.state.recoveryKey);
|
||||||
}, VALIDATION_THROTTLE_MS);
|
}, VALIDATION_THROTTLE_MS);
|
||||||
|
|
||||||
private async validateRecoveryKey(): Promise<void> {
|
private async validateRecoveryKey(recoveryKey: string): Promise<void> {
|
||||||
if (this.state.recoveryKey === "") {
|
if (recoveryKey === "") {
|
||||||
this.setState({
|
this.setState({
|
||||||
recoveryKeyValid: null,
|
recoveryKeyValid: null,
|
||||||
recoveryKeyCorrect: null,
|
recoveryKeyCorrect: null,
|
||||||
@@ -100,7 +100,7 @@ export default class AccessSecretStorageDialog extends React.PureComponent<IProp
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const cli = MatrixClientPeg.safeGet();
|
const cli = MatrixClientPeg.safeGet();
|
||||||
const decodedKey = decodeRecoveryKey(this.state.recoveryKey);
|
const decodedKey = decodeRecoveryKey(recoveryKey);
|
||||||
const correct = await cli.secretStorage.checkKey(decodedKey, this.props.keyInfo);
|
const correct = await cli.secretStorage.checkKey(decodedKey, this.props.keyInfo);
|
||||||
this.setState({
|
this.setState({
|
||||||
recoveryKeyValid: true,
|
recoveryKeyValid: true,
|
||||||
@@ -148,11 +148,12 @@ export default class AccessSecretStorageDialog extends React.PureComponent<IProp
|
|||||||
// right number of characters, but it's really just to make sure that what we're reading is
|
// right number of characters, but it's really just to make sure that what we're reading is
|
||||||
// text because we'll put it in the text field.
|
// text because we'll put it in the text field.
|
||||||
if (/^[123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz\s]+$/.test(contents)) {
|
if (/^[123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz\s]+$/.test(contents)) {
|
||||||
|
const recoveryKey = contents.trim();
|
||||||
this.setState({
|
this.setState({
|
||||||
recoveryKeyFileError: null,
|
recoveryKeyFileError: null,
|
||||||
recoveryKey: contents.trim(),
|
recoveryKey,
|
||||||
});
|
});
|
||||||
await this.validateRecoveryKey();
|
await this.validateRecoveryKey(recoveryKey);
|
||||||
} else {
|
} else {
|
||||||
this.setState({
|
this.setState({
|
||||||
recoveryKeyFileError: true,
|
recoveryKeyFileError: true,
|
||||||
|
|||||||
Reference in New Issue
Block a user