From d3c7a7ff1fe9f8715d050c8c11ccc3ae23cd5f34 Mon Sep 17 00:00:00 2001 From: "J. Ryan Stinnett" Date: Fri, 28 Feb 2020 13:47:12 +0000 Subject: [PATCH 1/2] Use latest backup status directly rather than via state This uses the latest backup status we just retrieved by returning from the lookup path (instead of using it indirectly via state). This is important because state updates are batched, so we can't rely on the value to be updated immediately like we were. Fixes https://github.com/vector-im/riot-web/issues/12562 --- .../secretstorage/CreateSecretStorageDialog.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/async-components/views/dialogs/secretstorage/CreateSecretStorageDialog.js b/src/async-components/views/dialogs/secretstorage/CreateSecretStorageDialog.js index 712f7d5f95..c42eb7d8dc 100644 --- a/src/async-components/views/dialogs/secretstorage/CreateSecretStorageDialog.js +++ b/src/async-components/views/dialogs/secretstorage/CreateSecretStorageDialog.js @@ -117,6 +117,11 @@ export default class CreateSecretStorageDialog extends React.PureComponent { backupInfo, backupSigStatus, }); + + return { + backupInfo, + backupSigStatus, + }; } async _queryKeyUploadAuth() { @@ -269,13 +274,13 @@ export default class CreateSecretStorageDialog extends React.PureComponent { const RestoreKeyBackupDialog = sdk.getComponent('dialogs.keybackup.RestoreKeyBackupDialog'); const { finished } = Modal.createTrackedDialog( 'Restore Backup', '', RestoreKeyBackupDialog, {showSummary: false}, null, - /* priority = */ false, /* static = */ true, + /* priority = */ false, /* static = */ false, ); await finished; - await this._fetchBackupInfo(); + const { backupSigStatus } = await this._fetchBackupInfo(); if ( - this.state.backupSigStatus.usable && + backupSigStatus.usable && this.state.canUploadKeysWithPasswordOnly && this.state.accountPassword ) { From 4db1d04764e554e5234230dfcd821487558da666 Mon Sep 17 00:00:00 2001 From: "J. Ryan Stinnett" Date: Fri, 28 Feb 2020 13:52:24 +0000 Subject: [PATCH 2/2] Fix warning about uncontrolled vs. controlled state --- .../views/dialogs/secretstorage/CreateSecretStorageDialog.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/async-components/views/dialogs/secretstorage/CreateSecretStorageDialog.js b/src/async-components/views/dialogs/secretstorage/CreateSecretStorageDialog.js index c42eb7d8dc..49b103ecf7 100644 --- a/src/async-components/views/dialogs/secretstorage/CreateSecretStorageDialog.js +++ b/src/async-components/views/dialogs/secretstorage/CreateSecretStorageDialog.js @@ -83,7 +83,7 @@ export default class CreateSecretStorageDialog extends React.PureComponent { // does the server offer a UI auth flow with just m.login.password // for /keys/device_signing/upload? canUploadKeysWithPasswordOnly: null, - accountPassword: props.accountPassword, + accountPassword: props.accountPassword || "", accountPasswordCorrect: null, // status of the key backup toggle switch useKeyBackup: true,