diff --git a/index.html b/index.html
index 290761b4b..49ef17ef0 100644
--- a/index.html
+++ b/index.html
@@ -182,7 +182,7 @@
Create a new wallet ·
- Import from file
+ Import a backup
@@ -191,14 +191,23 @@
diff --git a/js/controllers/import.js b/js/controllers/import.js
index d04fd54fc..1f6174892 100644
--- a/js/controllers/import.js
+++ b/js/controllers/import.js
@@ -21,13 +21,31 @@ angular.module('copay.import').controller('ImportController',
};
};
- $scope.import = function() {
- if ($scope.password) {
- if ($scope.backupText) {
- _importBackup($scope.backupText);
- } else {
- reader.readAsBinaryString($scope.file);
- }
+ $scope.import = function(form) {
+ if (form.$invalid) {
+ $rootScope.flashMessage = { message: 'There is an error in the form. Please, try again', type: 'error'};
+ return;
}
+
+ var backupFile = $scope.file;
+ var backupText = form.backupText.$modelValue;
+ var password = form.password.$modelValue;
+
+ if (!backupFile && !backupText) {
+ $rootScope.flashMessage = { message: 'Please, select your backup file or paste the text', type: 'error'};
+ return;
+ }
+
+ $scope.loading = true;
+
+ if (backupFile) {
+ reader.readAsBinaryString(backupFile);
+ }
+ else {
+ _importBackup(backupText);
+ }
+
+ $scope.loading = false;
+
};
});
diff --git a/js/models/core/WalletFactory.js b/js/models/core/WalletFactory.js
index ba6f33f85..f1b854f0c 100644
--- a/js/models/core/WalletFactory.js
+++ b/js/models/core/WalletFactory.js
@@ -65,6 +65,8 @@ WalletFactory.prototype.fromObj = function(obj) {
}
this.log('### WALLET OPENED:', w.id);
+ // store imported wallet
+ w.store();
return w;
};