mirror of https://github.com/BTCPrivate/copay.git
adds errorCb, handles blocks
This commit is contained in:
parent
ba40323b7b
commit
fe07348a5a
|
@ -63,6 +63,9 @@ angular.module('copayApp.controllers').controller('createController',
|
|||
if (err) {
|
||||
$log.debug(err);
|
||||
self.error = err;
|
||||
$timeout(function() {
|
||||
$rootScope.$apply();
|
||||
});
|
||||
}
|
||||
else {
|
||||
go.walletHome();
|
||||
|
|
|
@ -960,6 +960,9 @@ angular.module('copayApp.controllers').controller('indexController', function($r
|
|||
trailing: true
|
||||
});
|
||||
|
||||
self.debouncedUpdateHistory = lodash.throttle(function() {
|
||||
self.updateTxHistory();
|
||||
}, 60000);
|
||||
|
||||
$rootScope.$on('Local/Resume', function(event) {
|
||||
$log.debug('### Resume event');
|
||||
|
@ -1023,6 +1026,20 @@ angular.module('copayApp.controllers').controller('indexController', function($r
|
|||
});
|
||||
});
|
||||
|
||||
|
||||
$rootScope.$on('NewBlock', function() {
|
||||
if (self.pendingAmount) {
|
||||
self.updateAll();
|
||||
}
|
||||
|
||||
if (self.network =='testnet') {
|
||||
self.debouncedUpdateHistory();
|
||||
} else {
|
||||
self.updateTxHistory();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
$rootScope.$on('NewOutgoingTx', function() {
|
||||
self.updateAll({
|
||||
walletStatus: null,
|
||||
|
|
|
@ -12,6 +12,21 @@ angular.module('copayApp.services')
|
|||
return bwcService.getUtils();
|
||||
};
|
||||
|
||||
root.errorCb = function(err, prefix, cb) {
|
||||
var body = '';
|
||||
|
||||
prefix = gettext(prefix);
|
||||
if (!err || !err.code) return cb(prefix);
|
||||
|
||||
switch(err.code) {
|
||||
case 'CONNECTION_ERROR':
|
||||
body = gettext('Network connection error');
|
||||
;;
|
||||
}
|
||||
|
||||
return cb(prefix + ( body ? ': ' + body : ''));
|
||||
};
|
||||
|
||||
root.formatAmount = function(amount) {
|
||||
var config = configService.getSync().wallet.settings;
|
||||
if (config.unitCode == 'sat') return amount;
|
||||
|
@ -176,7 +191,7 @@ angular.module('copayApp.services')
|
|||
walletClient.createWallet('Personal Wallet', 'me', 1, 1, {
|
||||
network: 'livenet'
|
||||
}, function(err) {
|
||||
if (err) return cb(gettext('Error creating wallet. Check your internet connection'));
|
||||
if (err) return root.errorCb(err, 'Error creating wallet', cb);
|
||||
var p = Profile.create({
|
||||
credentials: [JSON.parse(walletClient.export())],
|
||||
});
|
||||
|
@ -198,7 +213,7 @@ angular.module('copayApp.services')
|
|||
walletClient.createWallet(opts.name, opts.myName || 'me', opts.m, opts.n, {
|
||||
network: opts.networkName
|
||||
}, function(err, secret) {
|
||||
if (err) return cb(gettext('Error creating wallet'));
|
||||
if (err) return root.errorCb(err, 'Error creating wallet', cb);
|
||||
|
||||
root.profile.credentials.push(JSON.parse(walletClient.export()));
|
||||
root.setWalletClients();
|
||||
|
|
Loading…
Reference in New Issue