refresh txps

This commit is contained in:
Matias Alejo Garcia 2016-08-23 13:20:57 -03:00
commit 4809050ae4
No known key found for this signature in database
GPG key ID: 02470DB551277AB3
3 changed files with 44 additions and 37 deletions

View file

@ -54,19 +54,14 @@ angular.module('copayApp.controllers').controller('txpDetailsController', functi
$scope.loading = true;
$scope.error = null;
$timeout(function() {
ongoingProcess.set('rejectTx', true);
walletService.rejectTx($scope.wallet, $scope.tx, function(err, txpr) {
ongoingProcess.set('rejectTx', false);
walletService.reject($scope.wallet, $scope.tx, function(err, txpr) {
if (err)
return setError(err, gettextCatalog.getString('Could not reject payment'));
$scope.close(txpr);
});
if (err) {
$scope.$emit('UpdateTx');
return setError(err, gettextCatalog.getString('Could not reject payment'));
}
$scope.close(txpr);
});
}, 10);
};
$scope.remove = function() {
@ -196,14 +191,8 @@ angular.module('copayApp.controllers').controller('txpDetailsController', functi
$scope.loading = null;
if (txp) {
var type = txStatus.notify(txp);
$scope.openStatusModal(type, txp, function() {
$scope.$emit('Local/TxProposalAction', txp.status == 'broadcasted');
});
} else {
$timeout(function() {
$scope.$emit('Local/TxProposalAction');
}, 100);
}
$scope.openStatusModal(type, txp, function() {});
}
$scope.cancel();
};

View file

@ -14,9 +14,7 @@ angular.module('copayApp.controllers').controller('tabHomeController',
$scope.txps = [];
return;
}
$scope.txps = txps.sort(function(a, b) {
return a.walletId.localeCompare(b.walletId);
});
$scope.txps = lodash.sortBy(txps, 'createdOn').reverse();
};
var formatPendingTxps = function(txps) {
@ -104,17 +102,19 @@ angular.module('copayApp.controllers').controller('tabHomeController',
self.updateWallet = function(wallet) {
$log.debug('Updating wallet:' + wallet.name)
walletService.getStatus(wallet, {}, function(err, status) {
if (err) {
console.log('[tab-home.js.35:err:]', $log.error(err)); //TODO
return;
}
if (status.pendingTxps && status.pendingTxps[0]) {
var txps = lodash.filter($scope.txps, function(x) {
return x.walletId != wallet.id;
});
var txps = lodash.filter($scope.txps, function(x) {
return x.walletId != wallet.id;
});
var wasAny = txps.length != $scope.txps.length;
if ( (status.pendingTxps && status.pendingTxps[0]) || wasAny ) {
txps = txps.concat(status.pendingTxps);
txps = formatPendingTxps(txps);
setPendingTxps(txps);
@ -134,7 +134,7 @@ angular.module('copayApp.controllers').controller('tabHomeController',
var wallet = profileService.getWallet(walletId);
self.updateWallet(wallet);
}),
$rootScope.$on('Local/TxAction', function(e, walletId, type, n) {
$rootScope.$on('Local/TxAction', function(e, walletId) {
var wallet = profileService.getWallet(walletId);
self.updateWallet(wallet);
}),