mirror of https://github.com/BTCPrivate/copay.git
add updateIndex to model
This commit is contained in:
parent
45e44fba19
commit
0da641d1b8
|
@ -36,10 +36,7 @@ angular.module('copayApp.controllers').controller('ImportController',
|
|||
$scope.error = 'Could not read wallet. Please check your password';
|
||||
} else {
|
||||
controllerUtils.installWalletHandlers($scope, wallet);
|
||||
updateStatus('Importing wallet - Scanning for transactions...');
|
||||
wallet.updateIndexes(function(err) {
|
||||
controllerUtils.setFocusedWallet(wallet);
|
||||
});
|
||||
controllerUtils.setFocusedWallet(wallet);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
|
|
@ -28,6 +28,7 @@ angular.module('copayApp.controllers').controller('ImportProfileController',
|
|||
passphraseConfig: config.passphraseConfig,
|
||||
}, function(err, iden) {
|
||||
if (err && !iden) {
|
||||
$scope.loading = false;
|
||||
$scope.error = (err.toString() || '').match('BADSTR') ? 'Bad password or corrupt profile file' : 'Unknown error';
|
||||
} else {
|
||||
var firstWallet = iden.getLastFocusedWallet();
|
||||
|
@ -54,14 +55,13 @@ angular.module('copayApp.controllers').controller('ImportProfileController',
|
|||
};
|
||||
|
||||
$scope.import = function(form) {
|
||||
$scope.loading = true;
|
||||
|
||||
if (form.$invalid) {
|
||||
$scope.loading = false;
|
||||
$scope.error = 'Please enter the required fields';
|
||||
return;
|
||||
}
|
||||
$rootScope.starting = true;
|
||||
|
||||
var backupFile = $scope.file;
|
||||
var backupText = form.backupText.$modelValue;
|
||||
var password = form.password.$modelValue;
|
||||
|
|
|
@ -275,6 +275,9 @@ Identity.prototype.close = function(cb) {
|
|||
}, cb);
|
||||
};
|
||||
|
||||
|
||||
// TODO: Add feedback function
|
||||
//
|
||||
Identity.prototype.importWalletFromObj = function(obj, opts, cb) {
|
||||
var self = this;
|
||||
preconditions.checkArgument(cb);
|
||||
|
@ -288,17 +291,21 @@ Identity.prototype.importWalletFromObj = function(obj, opts, cb) {
|
|||
|
||||
var w = importFunction(obj, readOpts);
|
||||
if (!w) return cb(new Error('Could not decrypt'));
|
||||
log.debug('Wallet decryped:' + w.getName());
|
||||
|
||||
self._checkVersion(w.version);
|
||||
self.addWallet(w);
|
||||
self.bindWallet(w);
|
||||
self.storeWallet(w, function(err) {
|
||||
if (err) return cb(err);
|
||||
|
||||
self.store({
|
||||
noWallets: true
|
||||
}, function(err) {
|
||||
return cb(err, w);
|
||||
log.debug('Updating Indexes for wallet:' + w.getName());
|
||||
w.updateIndexes(function(err) {
|
||||
log.debug('Adding wallet to profile:' + w.getName());
|
||||
self.addWallet(w);
|
||||
self.bindWallet(w);
|
||||
self.storeWallet(w, function(err) {
|
||||
if (err) return cb(err);
|
||||
self.store({
|
||||
noWallets: true
|
||||
}, function(err) {
|
||||
return cb(err, w);
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
|
@ -348,11 +355,16 @@ Identity.importFromFullJson = function(str, password, opts, cb) {
|
|||
opts.email = email;
|
||||
opts.password = password;
|
||||
|
||||
if (!email)
|
||||
return cb('BADSTR');
|
||||
|
||||
var iden = new Identity(opts);
|
||||
|
||||
json.wallets = json.wallets || {};
|
||||
|
||||
async.map(json.wallets, function(walletData, callback) {
|
||||
if (!walletData)
|
||||
return callback();
|
||||
|
||||
iden.importWalletFromObj(walletData, opts, function(err, w) {
|
||||
if (err) return callback(err);
|
||||
|
|
|
@ -1,6 +1,11 @@
|
|||
|
||||
<div class="home" ng-controller="ImportProfileController">
|
||||
|
||||
<div data-alert class="loading-screen" ng-show="loading">
|
||||
<i class="size-60 fi-bitcoin-circle icon-rotate spinner"></i> {{ importStatus|translate }}
|
||||
</div>
|
||||
|
||||
<div ng-show="!loading">
|
||||
<div class="large-4 large-centered medium-6 medium-centered columns">
|
||||
<div class="logo-setup">
|
||||
<img src="img/logo-negative-beta.svg" alt="Copay" width="146" height="59">
|
||||
|
@ -19,7 +24,7 @@
|
|||
|
||||
<div ng-show="!is_iOS">
|
||||
<legend for="backupFile" class="m10b">
|
||||
<span translate>Choose backup file from your computer</span> <i class="fi-laptop"></i>
|
||||
<span translate>Choose backup file</span>
|
||||
</legend>
|
||||
<input type="file" class="form-control"
|
||||
placeholder="{{'Select a backup file'|translate}}" name="backupFile" ng-model="backupFile" ng-file-select>
|
||||
|
@ -57,6 +62,7 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue