refactor scan after importing a wallet

This commit is contained in:
Matias Alejo Garcia 2015-11-14 17:29:45 -03:00
parent e9e8c6a0cb
commit 8c18995ae0
4 changed files with 25 additions and 20 deletions

View File

@ -170,11 +170,6 @@ angular.module('copayApp.controllers').controller('createController',
return;
}
if (opts.mnemonic || opts.externalSource || opts.extendedPrivateKey) {
if (opts.n == 1) {
$rootScope.$emit('Local/WalletImported', walletId);
}
}
});
}, 100);
}

View File

@ -923,9 +923,7 @@ angular.module('copayApp.controllers').controller('indexController', function($r
}
profileService.setWalletClients();
$timeout(function() {
$rootScope.$emit('Local/WalletImported', self.walletId);
}, 100);
self.startScan(self.walletId);
});
};
@ -1176,10 +1174,10 @@ angular.module('copayApp.controllers').controller('indexController', function($r
self.debouncedUpdate();
});
$rootScope.$on('Local/BackupDone', function(event) {
$rootScope.$on('Local/BackupDone', function(event, walletId) {
self.needsBackup = false;
$log.debug('Backup done');
storageService.setBackupFlag(self.walletId, function(err) {
storageService.setBackupFlag(walletId || self.walletId, function(err) {
$log.debug('Backup done stored');
});
});

View File

@ -129,11 +129,6 @@ angular.module('copayApp.controllers').controller('joinController',
return;
}
$timeout(function() {
var fc = profileService.focusedClient;
if (fc.isComplete() && (opts.mnemonic || opts.externalSource || opts.extendedPrivateKey))
$rootScope.$emit('Local/WalletImported', fc.credentials.walletId);
}, 2000);
});
}, 100);
};

View File

@ -276,8 +276,8 @@ angular.module('copayApp.services')
// check if exist
if (lodash.find(root.profile.credentials, {
'walletId': walletData.walletId
})) {
'walletId': walletData.walletId
})) {
return cb(gettext('Cannot join the same wallet more that once'));
}
} catch (ex) {
@ -379,9 +379,26 @@ angular.module('copayApp.services')
root.profile.credentials.push(JSON.parse(walletClient.export()));
root.setWalletClients();
root.setAndStoreFocus(walletId, function() {
storageService.storeProfile(root.profile, function(err) {
return cb(err, walletId);
var handleImport = function(cb) {
var isImport = opts.mnemonic || opts.externalSource || opts.extendedPrivateKey;
if (!isImport)
return cb();
$rootScope.$emit('Local/BackupDone', walletId);
if (!walletClient.isComplete())
return cb();
storageService.setCleanAndScanAddresses(walletId, cb);
};
handleImport(function() {
root.setAndStoreFocus(walletId, function() {
storageService.storeProfile(root.profile, function(err) {
return cb(err, walletId);
});
});
});
});