From 8b2ae3e20ff2eb67ff508afd97e40d24c6a2cb9d Mon Sep 17 00:00:00 2001 From: Zoe Date: Tue, 24 Mar 2020 12:24:12 +0000 Subject: [PATCH 1/2] If cached keys are present in the key backup dialog, use them --- .../keybackup/RestoreKeyBackupDialog.js | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/components/views/dialogs/keybackup/RestoreKeyBackupDialog.js b/src/components/views/dialogs/keybackup/RestoreKeyBackupDialog.js index 8e4a4e1e60..5f6f08453d 100644 --- a/src/components/views/dialogs/keybackup/RestoreKeyBackupDialog.js +++ b/src/components/views/dialogs/keybackup/RestoreKeyBackupDialog.js @@ -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() { this.setState({ loading: true, @@ -213,6 +231,15 @@ export default class RestoreKeyBackupDialog extends React.PureComponent { 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 (backupKeyStored) { return this._restoreWithSecretStorage(); From 936a4a00225871442e82a3bb99ff9002f2196316 Mon Sep 17 00:00:00 2001 From: Zoe Date: Wed, 25 Mar 2020 11:47:07 +0000 Subject: [PATCH 2/2] lint --- .../views/dialogs/keybackup/RestoreKeyBackupDialog.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/views/dialogs/keybackup/RestoreKeyBackupDialog.js b/src/components/views/dialogs/keybackup/RestoreKeyBackupDialog.js index 5f6f08453d..aecfa9bfd1 100644 --- a/src/components/views/dialogs/keybackup/RestoreKeyBackupDialog.js +++ b/src/components/views/dialogs/keybackup/RestoreKeyBackupDialog.js @@ -206,10 +206,10 @@ export default class RestoreKeyBackupDialog extends React.PureComponent { const recoverInfo = await MatrixClientPeg.get().restoreKeyBackupWithCache( undefined, /* targetRoomId */ undefined, /* targetSessionId */ - backupInfo + backupInfo, ); this.setState({ - recoverInfo + recoverInfo, }); return true; } catch (e) {