From fae282cf8e65c5d139343f2a5b89481f096fde86 Mon Sep 17 00:00:00 2001 From: Scott Nonnenberg Date: Wed, 13 Jun 2018 17:29:56 -0700 Subject: [PATCH] When user cancels filesystem dialog, reset to choice screen --- js/views/migration_view.js | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/js/views/migration_view.js b/js/views/migration_view.js index 8cc786c82e..87094b807b 100644 --- a/js/views/migration_view.js +++ b/js/views/migration_view.js @@ -319,25 +319,27 @@ Whisper.Migration.beginExport() .then(this.completeMigration.bind(this)) - .catch(this.onError.bind(this)); + .catch(function(error) { + // We ensure that a restart of the app acts as if the user never tried + // to export. + Whisper.Migration.cancel(); + + // We special-case the error we get when the user cancels out of the + // filesystem choice dialog: it's not shown an error. + if (!error || error.name !== 'ChooseError') { + this.error = error || new Error('in case we reject() null!'); + } + + // Because this is our first time attempting to export, we go back to + // the choice step. Compare this to the end of onClickChoose(). + this.selectStep(STEPS.CHOOSE); + }.bind(this)); }, completeMigration: function(target) { // This will prevent connection to the server on future app launches Whisper.Migration.markComplete(target); this.selectStep(STEPS.COMPLETE); }, - onError: function(error) { - if (error && error.name === 'ChooseError') { - this.cancelMigration(); - } else { - this.error = error || new Error('in case we reject() null!'); - this.cancelMigration(); - } - }, - cancelMigration: function() { - Whisper.Migration.cancel(); - this.render(); - } }); }());