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 = ( +
+ + {restoreButtonCaption} +     + + {_t("Delete Backup")} + +
+ ); + if (this.state.backupKeyStored && !SettingsStore.isFeatureEnabled("feature_cross_signing")) { + 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
{clientBackupStatus}
@@ -351,14 +382,7 @@ export default class KeyBackupPanel extends React.PureComponent {
{backupSigStatuses}
{trustedLocally}
-
- - {restoreButtonCaption} -     - - { _t("Delete Backup") } - -
+ {buttonRow}
; } else { // This is a temporary button for testing the new path which stores diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index f44d3d7b67..a89f44b2c3 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -545,6 +545,7 @@ "Backup has an invalid signature from unverified device ": "Backup has an invalid signature from unverified device ", "Backup is not signed by any of your devices": "Backup is not signed by any of your devices", "This backup is trusted because it has been restored on this device": "This backup is trusted because it has been restored on this device", + "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.": "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.", "Backup version: ": "Backup version: ", "Algorithm: ": "Algorithm: ", "Backup key stored: ": "Backup key stored: ",