Merge pull request #4273 from matrix-org/foldleft/12704-key-requests
If cached keys are present in the key backup dialog, use them
This commit is contained in:
commit
b7013c6f5d
1 changed files with 27 additions and 0 deletions
|
@ -200,6 +200,24 @@ export default class RestoreKeyBackupDialog extends React.PureComponent {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async _restoreWithCachedKey(backupInfo) {
|
||||||
|
if (!backupInfo) return false;
|
||||||
|
try {
|
||||||
|
const recoverInfo = await MatrixClientPeg.get().restoreKeyBackupWithCache(
|
||||||
|
undefined, /* targetRoomId */
|
||||||
|
undefined, /* targetSessionId */
|
||||||
|
backupInfo,
|
||||||
|
);
|
||||||
|
this.setState({
|
||||||
|
recoverInfo,
|
||||||
|
});
|
||||||
|
return true;
|
||||||
|
} catch (e) {
|
||||||
|
console.log("restoreWithCachedKey failed:", e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async _loadBackupStatus() {
|
async _loadBackupStatus() {
|
||||||
this.setState({
|
this.setState({
|
||||||
loading: true,
|
loading: true,
|
||||||
|
@ -213,6 +231,15 @@ export default class RestoreKeyBackupDialog extends React.PureComponent {
|
||||||
backupKeyStored,
|
backupKeyStored,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const gotCache = await this._restoreWithCachedKey(backupInfo);
|
||||||
|
if (gotCache) {
|
||||||
|
console.log("RestoreKeyBackupDialog: found cached backup key");
|
||||||
|
this.setState({
|
||||||
|
loading: false,
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// If the backup key is stored, we can proceed directly to restore.
|
// If the backup key is stored, we can proceed directly to restore.
|
||||||
if (backupKeyStored) {
|
if (backupKeyStored) {
|
||||||
return this._restoreWithSecretStorage();
|
return this._restoreWithSecretStorage();
|
||||||
|
|
Loading…
Reference in a new issue