diff --git a/index.html b/index.html
index 9994794a6..51dffc4cd 100644
--- a/index.html
+++ b/index.html
@@ -176,7 +176,7 @@
Create a new wallet ·
- Import from file
+ Restore a backup
@@ -185,14 +185,27 @@
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;
+
};
});