diff --git a/index.html b/index.html
index e7825c84c..52739204e 100644
--- a/index.html
+++ b/index.html
@@ -276,7 +276,7 @@
- Importing wallet...
+ {{ importStatus }}
{{title}}
diff --git a/js/controllers/import.js b/js/controllers/import.js
index c3401862b..4ba9d0d0d 100644
--- a/js/controllers/import.js
+++ b/js/controllers/import.js
@@ -3,10 +3,19 @@
angular.module('copayApp.controllers').controller('ImportController',
function($scope, $rootScope, walletFactory, controllerUtils, Passphrase) {
$scope.title = 'Import a backup';
+ $scope.importStatus = 'Importing wallet - Reading backup...';
+
var reader = new FileReader();
+
+ var updateStatus = function(status) {
+ $scope.importStatus = status;
+ $scope.$digest();
+ }
+
var _importBackup = function(encryptedObj) {
Passphrase.getBase64Async($scope.password, function(passphrase) {
- walletFactory.import(encryptedObj, passphrase, function(err, w) {
+ updateStatus('Importing wallet - Setting things up...');
+ var w = walletFactory.import(encryptedObj, passphrase, function(err, w) {
if (err) {
$scope.loading = false;
$rootScope.$flashMessage = {
@@ -19,6 +28,10 @@ angular.module('copayApp.controllers').controller('ImportController',
$rootScope.wallet = w;
controllerUtils.startNetwork($rootScope.wallet, $scope);
});
+
+ w.on('updatingIndexes', function(){
+ updateStatus('Importing wallet - We are almost there...');
+ });
});
};
diff --git a/js/models/core/Wallet.js b/js/models/core/Wallet.js
index 0bfa3dcf4..a87ab10d1 100644
--- a/js/models/core/Wallet.js
+++ b/js/models/core/Wallet.js
@@ -755,6 +755,7 @@ Wallet.prototype.updateIndexes = function(callback) {
if (changeIndex != -1)
self.publicKeyRing.indexes.changeIndex = changeIndex + 1;
+ self.emit('updatingIndexes');
start = self.publicKeyRing.indexes.receiveIndex;
self.indexDiscovery(start, false, 20, function(err, receiveIndex) {
if (err) return callback(err);
diff --git a/js/models/core/WalletFactory.js b/js/models/core/WalletFactory.js
index 03d59e2ea..35a574ebd 100644
--- a/js/models/core/WalletFactory.js
+++ b/js/models/core/WalletFactory.js
@@ -84,6 +84,7 @@ WalletFactory.prototype.import = function(base64, password, cb) {
self.log('Indexes updated');
cb(null, w);
});
+ return w;
}
WalletFactory.prototype.read = function(walletId) {
diff --git a/test/test.Wallet.js b/test/test.Wallet.js
index 14a7ee490..17f8b3901 100644
--- a/test/test.Wallet.js
+++ b/test/test.Wallet.js
@@ -743,7 +743,7 @@ describe('Wallet model', function() {
var spyEmit = sinon.spy(w, 'emit');
w.updateIndexes(function(err) {
sinon.assert.callCount(spyStore, 1);
- sinon.assert.callCount(spyEmit, 1);
+ sinon.assert.callCount(spyEmit, 2);
done();
});
});