fix refresh after delete

This commit is contained in:
Matias Alejo Garcia 2016-09-02 14:55:18 -03:00
parent 8c43f55756
commit 6388a97eb5
No known key found for this signature in database
GPG Key ID: 02470DB551277AB3
7 changed files with 38 additions and 28 deletions

View File

@ -42,7 +42,7 @@
"url": "https://github.com/bitpay/copay/issues" "url": "https://github.com/bitpay/copay/issues"
}, },
"dependencies": { "dependencies": {
"bitcore-wallet-client": "4.1.0", "bitcore-wallet-client": "4.2.0",
"coveralls": "^2.11.9", "coveralls": "^2.11.9",
"express": "^4.11.2", "express": "^4.11.2",
"fs": "0.0.2", "fs": "0.0.2",

View File

@ -45,7 +45,7 @@
"url": "https://github.com/bitpay/copay/issues" "url": "https://github.com/bitpay/copay/issues"
}, },
"dependencies": { "dependencies": {
"bitcore-wallet-client": "4.1.0", "bitcore-wallet-client": "4.2.0",
"coveralls": "^2.11.9", "coveralls": "^2.11.9",
"express": "^4.11.2", "express": "^4.11.2",
"fs": "0.0.2", "fs": "0.0.2",

View File

@ -5,6 +5,17 @@ angular.module('copayApp.controllers').controller('confirmController', function(
var cachedTxp = {}; var cachedTxp = {};
var isChromeApp = platformInfo.isChromeApp; var isChromeApp = platformInfo.isChromeApp;
$scope.$on('Wallet/Changed', function(event, wallet) {
if (lodash.isEmpty(wallet)) {
$log.debug('No wallet provided');
return;
}
$log.debug('Wallet changed: ' + wallet.name);
setWallet(wallet, true);
});
$scope.showDescriptionPopup = function() { $scope.showDescriptionPopup = function() {
var commentPopup = $ionicPopup.show({ var commentPopup = $ionicPopup.show({
templateUrl: "views/includes/note.html", templateUrl: "views/includes/note.html",
@ -130,15 +141,6 @@ angular.module('copayApp.controllers').controller('confirmController', function(
}); });
}; };
$scope.$on('Wallet/Changed', function(event, wallet) {
if (lodash.isEmpty(wallet)) {
$log.debug('No wallet provided');
return;
}
$log.debug('Wallet changed: ' + wallet.name);
setWallet(wallet, true);
});
function setWallet(wallet, delayed) { function setWallet(wallet, delayed) {
var stop; var stop;
$scope.wallet = wallet; $scope.wallet = wallet;
@ -255,7 +257,9 @@ angular.module('copayApp.controllers').controller('confirmController', function(
}); });
} }
ongoingProcess.set('creatingTx', true);
createTx(wallet, false, function(err, txp) { createTx(wallet, false, function(err, txp) {
ongoingProcess.set('creatingTx', false);
if (err) return; if (err) return;
walletService.publishAndSign(wallet, txp, function(err, txp) { walletService.publishAndSign(wallet, txp, function(err, txp) {
if (err) return setSendError(err); if (err) return setSendError(err);

View File

@ -34,7 +34,7 @@ angular.module('copayApp.controllers').controller('txpDetailsController', functi
walletService.publishAndSign($scope.wallet, $scope.tx, function(err, txp) { walletService.publishAndSign($scope.wallet, $scope.tx, function(err, txp) {
$scope.$emit('UpdateTx'); $scope.$emit('UpdateTx');
if (err) return setSendError(err); if (err) return setSendError(err);
$scope.close(true); $scope.close();
}); });
}; };
@ -50,7 +50,7 @@ angular.module('copayApp.controllers').controller('txpDetailsController', functi
if (err) if (err)
return setError(err, gettextCatalog.getString('Could not reject payment')); return setError(err, gettextCatalog.getString('Could not reject payment'));
$scope.close(true); $scope.close();
}); });
@ -70,7 +70,7 @@ angular.module('copayApp.controllers').controller('txpDetailsController', functi
return setError(err, gettextCatalog.getString('Could not delete payment proposal')); return setError(err, gettextCatalog.getString('Could not delete payment proposal'));
} }
$scope.close(true); $scope.close();
}); });
}, 10); }, 10);
}; };
@ -87,7 +87,7 @@ angular.module('copayApp.controllers').controller('txpDetailsController', functi
return setError(err, gettextCatalog.getString('Could not broadcast payment')); return setError(err, gettextCatalog.getString('Could not broadcast payment'));
} }
$scope.close(true); $scope.close();
}); });
}, 10); }, 10);
}; };
@ -172,10 +172,7 @@ angular.module('copayApp.controllers').controller('txpDetailsController', functi
}); });
}; };
$scope.close = function(shouldEmit) { $scope.close = function() {
if (shouldEmit)
$rootScope.$emit('Local/TxAction', $scope.wallet.id);
$scope.loading = null; $scope.loading = null;
$scope.txpDetailsModal.hide(); $scope.txpDetailsModal.hide();
}; };

View File

@ -106,6 +106,7 @@ angular.module('copayApp.controllers').controller('tabHomeController',
$scope.updateWallet(wallet); $scope.updateWallet(wallet);
}), }),
$rootScope.$on('Local/TxAction', function(e, walletId) { $rootScope.$on('Local/TxAction', function(e, walletId) {
$log.debug('Got action for wallet '+ walletId);
var wallet = profileService.getWallet(walletId); var wallet = profileService.getWallet(walletId);
$scope.updateWallet(wallet); $scope.updateWallet(wallet);
}), }),

View File

@ -123,7 +123,6 @@ angular.module('copayApp.services')
if (wallet.cachedActivity) if (wallet.cachedActivity)
wallet.cachedActivity.isValid = false; wallet.cachedActivity.isValid = false;
if (wallet.cachedTxps) if (wallet.cachedTxps)
wallet.cachedTxps.isValid = false; wallet.cachedTxps.isValid = false;

View File

@ -92,13 +92,17 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
root.invalidateCache = function(wallet) { root.invalidateCache = function(wallet) {
if (wallet.cachedStatus) { if (wallet.cachedStatus)
wallet.cachedStatus.isValid = false; wallet.cachedStatus.isValid = false;
}
if (wallet.completeHistory) { if (wallet.completeHistory)
wallet.completeHistory.isValid = false; wallet.completeHistory.isValid = false;
}
if (wallet.cachedActivity)
wallet.cachedActivity.isValid = false;
if (wallet.cachedTxps)
wallet.cachedTxps.isValid = false;
}; };
root.getStatus = function(wallet, opts, cb) { root.getStatus = function(wallet, opts, cb) {
@ -623,6 +627,10 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
wallet.removeTxProposal(txp, function(err) { wallet.removeTxProposal(txp, function(err) {
$log.debug('Transaction removed'); $log.debug('Transaction removed');
root.invalidateCache(wallet);
$rootScope.$emit('Local/TxAction', wallet.id);
return cb(err); return cb(err);
}); });
}; };
@ -864,8 +872,8 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
ongoingProcess.set('rejectTx', true); ongoingProcess.set('rejectTx', true);
root.rejectTx(wallet, txp, function(err, txpr) { root.rejectTx(wallet, txp, function(err, txpr) {
root.invalidateCache(wallet); root.invalidateCache(wallet);
ongoingProcess.set('rejectTx', false); ongoingProcess.set('rejectTx', false);
if (err) return cb(err); if (err) return cb(err);
$rootScope.$emit('Local/TxAction', wallet.id); $rootScope.$emit('Local/TxAction', wallet.id);
@ -935,6 +943,7 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
var msg = err.message ? var msg = err.message ?
err.message : err.message :
gettext('The payment was created but could not be completed. Please try again from home screen'); gettext('The payment was created but could not be completed. Please try again from home screen');
$rootScope.$emit('Local/TxAction', wallet.id); $rootScope.$emit('Local/TxAction', wallet.id);
return cb(msg); return cb(msg);
} }
@ -945,18 +954,18 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
ongoingProcess.set('broadcastingTx', false); ongoingProcess.set('broadcastingTx', false);
if (err) return cb('sign error' + err); if (err) return cb('sign error' + err);
$rootScope.$emit('Local/TxAction', wallet.id);
var type = root.getViewStatus(wallet, broadcastedTxp); var type = root.getViewStatus(wallet, broadcastedTxp);
root.openStatusModal(type, broadcastedTxp, function() { root.openStatusModal(type, broadcastedTxp, function() {
$rootScope.$emit('Local/TxAction', wallet.id);
}); });
return cb(null, broadcastedTxp) return cb(null, broadcastedTxp)
}); });
} else { } else {
$rootScope.$emit('Local/TxAction', wallet.id);
var type = root.getViewStatus(wallet, signedTxp); var type = root.getViewStatus(wallet, signedTxp);
root.openStatusModal(type, signedTxp, function() { root.openStatusModal(type, signedTxp, function() {
root.invalidateCache(wallet);
$rootScope.$emit('Local/TxAction', wallet.id);
}); });
return cb(null, signedTxp); return cb(null, signedTxp);
} }