Skip to content

Commit b5993aa

Browse files
authored
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
1 parent e1b2e3a commit b5993aa

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/components/views/dialogs/security/AccessSecretStorageDialog.tsx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,11 @@ export default class AccessSecretStorageDialog extends React.PureComponent<IProp
8686
};
8787

8888
private validateRecoveryKeyOnChange = debounce(async (): Promise<void> => {
89-
await this.validateRecoveryKey();
89+
await this.validateRecoveryKey(this.state.recoveryKey);
9090
}, VALIDATION_THROTTLE_MS);
9191

92-
private async validateRecoveryKey(): Promise<void> {
93-
if (this.state.recoveryKey === "") {
92+
private async validateRecoveryKey(recoveryKey: string): Promise<void> {
93+
if (recoveryKey === "") {
9494
this.setState({
9595
recoveryKeyValid: null,
9696
recoveryKeyCorrect: null,
@@ -100,7 +100,7 @@ export default class AccessSecretStorageDialog extends React.PureComponent<IProp
100100

101101
try {
102102
const cli = MatrixClientPeg.safeGet();
103-
const decodedKey = decodeRecoveryKey(this.state.recoveryKey);
103+
const decodedKey = decodeRecoveryKey(recoveryKey);
104104
const correct = await cli.secretStorage.checkKey(decodedKey, this.props.keyInfo);
105105
this.setState({
106106
recoveryKeyValid: true,
@@ -148,11 +148,12 @@ export default class AccessSecretStorageDialog extends React.PureComponent<IProp
148148
// right number of characters, but it's really just to make sure that what we're reading is
149149
// text because we'll put it in the text field.
150150
if (/^[123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz\s]+$/.test(contents)) {
151+
const recoveryKey = contents.trim();
151152
this.setState({
152153
recoveryKeyFileError: null,
153-
recoveryKey: contents.trim(),
154+
recoveryKey,
154155
});
155-
await this.validateRecoveryKey();
156+
await this.validateRecoveryKey(recoveryKey);
156157
} else {
157158
this.setState({
158159
recoveryKeyFileError: true,

0 commit comments

Comments
 (0)