diff --git a/src/components/views/settings/KeyBackupPanel.js b/src/components/views/settings/KeyBackupPanel.js index 1a28b89354..559b1e0ba1 100644 --- a/src/components/views/settings/KeyBackupPanel.js +++ b/src/components/views/settings/KeyBackupPanel.js @@ -180,10 +180,23 @@ export default class KeyBackupPanel extends React.PureComponent { }); } - _restoreBackup = () => { - const RestoreKeyBackupDialog = sdk.getComponent('dialogs.keybackup.RestoreKeyBackupDialog'); - Modal.createTrackedDialog('Restore Backup', '', RestoreKeyBackupDialog, { - }); + _restoreBackup = async () => { + // Use legacy path if backup key not stored in secret storage + if (!this.state.backupKeyStored) { + const RestoreKeyBackupDialog = sdk.getComponent('dialogs.keybackup.RestoreKeyBackupDialog'); + Modal.createTrackedDialog('Restore Backup', '', RestoreKeyBackupDialog); + return; + } + + try { + await accessSecretStorage(async () => { + await MatrixClientPeg.get().restoreKeyBackupWithSecretStorage( + this.state.backupInfo, + ); + }); + } catch (e) { + console.log("Error restoring backup", e); + } } render() { @@ -340,6 +353,24 @@ export default class KeyBackupPanel extends React.PureComponent { trustedLocally = _t("This backup is trusted because it has been restored on this device"); } + let buttonRow = ( +
⚠️ {_t( + "Backup key stored in secret storage, but this feature is not " + + "enabled on this device. Please enable cross-signing in Labs to " + + "modify key backup state.", + )}
; + } + return