refresh txps
This commit is contained in:
parent
bc4f7e841e
commit
4809050ae4
3 changed files with 44 additions and 37 deletions
|
|
@ -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();
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}),
|
||||
|
|
|
|||
|
|
@ -838,18 +838,34 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
|
|||
});
|
||||
};
|
||||
|
||||
|
||||
root.reject = function(wallet, txp, cb) {
|
||||
ongoingProcess.set('rejectTx', true);
|
||||
root.rejectTx(wallet, txp, function(err, txpr) {
|
||||
root.invalidateCache(wallet);
|
||||
|
||||
ongoingProcess.set('rejectTx', false);
|
||||
if (err) return cb(err);
|
||||
|
||||
$rootScope.$emit('Local/TxAction', wallet.id);
|
||||
return cb(null, txpr);
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
root.onlyPublish = function(wallet, txp, cb) {
|
||||
ongoingProcess.set('sendingTx', true);
|
||||
root.publishTx(wallet, txp, function(err, publishedTxp) {
|
||||
root.invalidateCache(wallet);
|
||||
|
||||
ongoingProcess.set('sendingTx', false);
|
||||
if (err) return cb(err);
|
||||
|
||||
var type = txStatus.notify(createdTxp);
|
||||
root.openStatusModal(type, createdTxp, function() {
|
||||
// TODO?
|
||||
//return $scope.$emit('Local/TxProposalAction');
|
||||
$rootScope.$emit('Local/TxAction', wallet.id);
|
||||
return;
|
||||
});
|
||||
|
||||
return cb(null, publishedTxp);
|
||||
});
|
||||
};
|
||||
|
|
@ -878,15 +894,18 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
|
|||
|
||||
ongoingProcess.set('signingTx', true);
|
||||
root.signTx(wallet, publishedTxp, function(err, signedTxp) {
|
||||
ongoingProcess.set('signingTx', false);
|
||||
root.lock(wallet);
|
||||
|
||||
ongoingProcess.set('signingTx', false);
|
||||
root.invalidateCache(wallet);
|
||||
|
||||
|
||||
if (err) {
|
||||
// TODO?
|
||||
//$scope.$emit('Local/TxProposalAction');
|
||||
var msg = err.message ?
|
||||
err.message :
|
||||
gettext('The payment was created but could not be completed. Please try again from home screen');
|
||||
$rootScope.$emit('Local/TxAction', wallet.id);
|
||||
return cb(err);
|
||||
}
|
||||
|
||||
|
|
@ -898,8 +917,7 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
|
|||
|
||||
var type = txStatus.notify(broadcastedTxp);
|
||||
root.openStatusModal(type, broadcastedTxp, function() {
|
||||
// TODO?
|
||||
//$scope.$emit('Local/TxProposalAction', broadcastedTxp.status == 'broadcasted');
|
||||
$rootScope.$emit('Local/TxAction', wallet.id);
|
||||
});
|
||||
|
||||
return cb(null, broadcastedTxp)
|
||||
|
|
@ -907,8 +925,8 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
|
|||
} else {
|
||||
var type = txStatus.notify(signedTxp);
|
||||
root.openStatusModal(type, signedTxp, function() {
|
||||
// TODO?
|
||||
//$scope.$emit('Local/TxProposalAction');
|
||||
root.invalidateCache(wallet);
|
||||
$rootScope.$emit('Local/TxAction', wallet.id);
|
||||
});
|
||||
return cb(null, signedTxp);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue