unify strings to "payment". Add retry on balance update

This commit is contained in:
Matias Alejo Garcia 2015-05-18 16:21:36 -03:00
commit 17deda9000
8 changed files with 92 additions and 55 deletions

View file

@ -145,7 +145,11 @@ angular.module('copayApp.controllers').controller('indexController', function($r
$rootScope.$emit('Local/TabChanged', tab);
};
self.updateAll = function(walletStatus) {
self.updateAll = function(walletStatus, untilItChanges, initBalance, tries) {
tries = tries || 0;
if (untilItChanges && lodash.isUndefined(initBalance)) {
initBalance = self.totalBalanceSat;
}
var get = function(cb) {
if (walletStatus)
return cb(null, walletStatus);
@ -169,6 +173,11 @@ angular.module('copayApp.controllers').controller('indexController', function($r
self.setOngoingProcess('updatingStatus', true);
$log.debug('Updating Status:', fc);
get(function(err, walletStatus) {
if (!err && untilItChanges && initBalance == walletStatus.balance.totalAmount && tries < 10) {
return $timeout(function() {
return self.updateAll(null, true, initBalance, ++tries);
}, 1000);
}
self.setOngoingProcess('updatingStatus', false);
if (err) {
self.handleError(err);
@ -711,8 +720,8 @@ angular.module('copayApp.controllers').controller('indexController', function($r
lodash.each(['NewOutgoingTx', 'NewTxProposal', 'TxProposalFinallyRejected', 'transactionProposalRemoved', 'TxProposalRemoved',
'Local/NewTxProposal', 'Local/TxProposalAction', 'ScanFinished'
], function(eventName) {
$rootScope.$on(eventName, function() {
self.updateAll();
$rootScope.$on(eventName, function(event, untilItChanges) {
self.updateAll(null, untilItChanges);
$timeout(function() {
self.updateTxHistory();
}, 3000);

View file

@ -190,7 +190,7 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
return;
};
self.setOngoingProcess(gettext('Signing transaction'));
self.setOngoingProcess(gettext('Signing payment'));
$scope.loading = true;
$scope.error = null;
$timeout(function() {
@ -229,7 +229,7 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
};
$scope.reject = function(txp) {
self.setOngoingProcess(gettext('Rejecting transaction'));
self.setOngoingProcess(gettext('Rejecting payment'));
$scope.loading = true;
$scope.error = null;
$timeout(function() {
@ -249,7 +249,7 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
$scope.remove = function(txp) {
self.setOngoingProcess(gettext('Deleting transaction'));
self.setOngoingProcess(gettext('Deleting payment'));
$scope.loading = true;
$scope.error = null;
$timeout(function() {
@ -270,7 +270,7 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
};
$scope.broadcast = function(txp) {
self.setOngoingProcess(gettext('Broadcasting transaction'));
self.setOngoingProcess(gettext('Broadcasting Payment'));
$scope.loading = true;
$scope.error = null;
$timeout(function() {
@ -313,7 +313,7 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
self.setOngoingProcess();
if (txp) {
txStatus.notify(txp, function() {
$scope.$emit('Local/TxProposalAction');
$scope.$emit('Local/TxProposalAction', true);
});
} else {
$timeout(function() {

View file

@ -4,7 +4,7 @@ angular.module('copayApp.services')
var root = {};
var groupingTime = 4000;
var groupingTime = 5000;
var lastNotificationOnWallet = {};
root.getLast = function(walletId) {
@ -57,23 +57,23 @@ angular.module('copayApp.services')
switch (notificationData.type) {
case 'NewTxProposal':
notification.new(gettext('New Transaction'),
notification.new(gettext('New Payment Proposal'),
name, {color: color} );
break;
case 'TxProposalAcceptedBy':
notification.success(gettext('Transaction Signed'),
notification.success(gettext('Payment Proposal Signed by Copayer'),
name, {color: color} );
break;
case 'TxProposalRejectedBy':
notification.error(gettext('Transaction Rejected'),
notification.error(gettext('Payment Proposal Rejected by Copayer'),
name, {color: color} );
break;
case 'TxProposalFinallyRejected':
notification.error(gettext('A transaction was finally rejected'),
notification.error(gettext('Payment Proposal Finally Rejected'),
name, {color: color} );
break;
case 'NewOutgoingTx':
notification.sent(gettext('Transaction Sent'),
notification.sent(gettext('Payment Proposal Sent'),
name, {color: color} );
break;
case 'NewIncomingTx':

View file

@ -5,31 +5,35 @@ angular.module('copayApp.services').factory('txStatus', function($modal, lodash,
root.notify = function(txp, cb) {
var fc = profileService.focusedClient;
var msg;
var status = txp.status;
var type;
if (status == 'broadcasted') {
msg = gettext('Transaction broadcasted');
type = 'broadcasted';
} else {
var n = txp.actions.length;
var action = lodash.find(txp.actions, {
copayerId: fc.credentials.copayerId
});
if (!action) {
msg = gettext('Transaction proposal created');
if (!action || (action.type == 'accept' && n == 1)) {
type = 'created';
} else if (action.type == 'accept') {
msg = gettext('Transaction proposal signed');
type = 'accepted';
} else if (action.type == 'reject') {
msg = gettext('Transaction was rejected');
type = 'rejected';
} else {
throw new Error('Unknown type:' + type);
}
}
root.openModal(msg, cb);
root.openModal(type, cb);
};
root.openModal = function(statusStr, cb) {
root.openModal = function(type, cb) {
var ModalInstanceCtrl = function($scope, $modalInstance) {
$scope.statusStr = statusStr;
$scope.type = type;
$scope.cancel = function() {
$modalInstance.dismiss('cancel');
};