@@ -70,6 +70,7 @@ export default class CreateSecretStorageDialog extends React.PureComponent {
7070 this . _recoveryKey = null ;
7171 this . _recoveryKeyNode = null ;
7272 this . _setZxcvbnResultTimeout = null ;
73+ this . _backupKey = null ;
7374
7475 this . state = {
7576 phase : PHASE_LOADING ,
@@ -243,7 +244,15 @@ export default class CreateSecretStorageDialog extends React.PureComponent {
243244 createSecretStorageKey : async ( ) => this . _recoveryKey ,
244245 keyBackupInfo : this . state . backupInfo ,
245246 setupNewKeyBackup : ! this . state . backupInfo && this . state . useKeyBackup ,
246- getKeyBackupPassphrase : promptForBackupPassphrase ,
247+ getKeyBackupPassphrase : ( ) => {
248+ // We may already have the backup key if we earlier went
249+ // through the restore backup path, so pass it along
250+ // rather than prompting again.
251+ if ( this . _backupKey ) {
252+ return this . _backupKey ;
253+ }
254+ return promptForBackupPassphrase ( ) ;
255+ } ,
247256 } ) ;
248257 }
249258 this . setState ( {
@@ -272,10 +281,18 @@ export default class CreateSecretStorageDialog extends React.PureComponent {
272281 }
273282
274283 _restoreBackup = async ( ) => {
284+ // It's possible we'll need the backup key later on for bootstrapping,
285+ // so let's stash it here, rather than prompting for it twice.
286+ const keyCallback = k => this . _backupKey = k ;
287+
275288 const RestoreKeyBackupDialog = sdk . getComponent ( 'dialogs.keybackup.RestoreKeyBackupDialog' ) ;
276289 const { finished } = Modal . createTrackedDialog (
277- 'Restore Backup' , '' , RestoreKeyBackupDialog , { showSummary : false } , null ,
278- /* priority = */ false , /* static = */ false ,
290+ 'Restore Backup' , '' , RestoreKeyBackupDialog ,
291+ {
292+ showSummary : false ,
293+ keyCallback,
294+ } ,
295+ null , /* priority = */ false , /* static = */ false ,
279296 ) ;
280297
281298 await finished ;
0 commit comments