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"
},
"dependencies": {
"bitcore-wallet-client": "4.1.0",
"bitcore-wallet-client": "4.2.0",
"coveralls": "^2.11.9",
"express": "^4.11.2",
"fs": "0.0.2",

View File

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

View File

@ -5,6 +5,17 @@ angular.module('copayApp.controllers').controller('confirmController', function(
var cachedTxp = {};
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() {
var commentPopup = $ionicPopup.show({
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) {
var stop;
$scope.wallet = wallet;
@ -255,7 +257,9 @@ angular.module('copayApp.controllers').controller('confirmController', function(
});
}
ongoingProcess.set('creatingTx', true);
createTx(wallet, false, function(err, txp) {
ongoingProcess.set('creatingTx', false);
if (err) return;
walletService.publishAndSign(wallet, txp, function(err, txp) {
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) {
$scope.$emit('UpdateTx');
if (err) return setSendError(err);
$scope.close(true);
$scope.close();
});
};
@ -50,7 +50,7 @@ angular.module('copayApp.controllers').controller('txpDetailsController', functi
if (err)
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'));
}
$scope.close(true);
$scope.close();
});
}, 10);
};
@ -87,7 +87,7 @@ angular.module('copayApp.controllers').controller('txpDetailsController', functi
return setError(err, gettextCatalog.getString('Could not broadcast payment'));
}
$scope.close(true);
$scope.close();
});
}, 10);
};
@ -172,10 +172,7 @@ angular.module('copayApp.controllers').controller('txpDetailsController', functi
});
};
$scope.close = function(shouldEmit) {
if (shouldEmit)
$rootScope.$emit('Local/TxAction', $scope.wallet.id);
$scope.close = function() {
$scope.loading = null;
$scope.txpDetailsModal.hide();
};

View File

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

View File

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

View File

@ -92,13 +92,17 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
root.invalidateCache = function(wallet) {
if (wallet.cachedStatus) {
if (wallet.cachedStatus)
wallet.cachedStatus.isValid = false;
}
if (wallet.completeHistory) {
if (wallet.completeHistory)
wallet.completeHistory.isValid = false;
}
if (wallet.cachedActivity)
wallet.cachedActivity.isValid = false;
if (wallet.cachedTxps)
wallet.cachedTxps.isValid = false;
};
root.getStatus = function(wallet, opts, cb) {
@ -623,6 +627,10 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
wallet.removeTxProposal(txp, function(err) {
$log.debug('Transaction removed');
root.invalidateCache(wallet);
$rootScope.$emit('Local/TxAction', wallet.id);
return cb(err);
});
};
@ -864,8 +872,8 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
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);
@ -935,6 +943,7 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
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(msg);
}
@ -945,18 +954,18 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
ongoingProcess.set('broadcastingTx', false);
if (err) return cb('sign error' + err);
$rootScope.$emit('Local/TxAction', wallet.id);
var type = root.getViewStatus(wallet, broadcastedTxp);
root.openStatusModal(type, broadcastedTxp, function() {
$rootScope.$emit('Local/TxAction', wallet.id);
});
return cb(null, broadcastedTxp)
});
} else {
$rootScope.$emit('Local/TxAction', wallet.id);
var type = root.getViewStatus(wallet, signedTxp);
root.openStatusModal(type, signedTxp, function() {
root.invalidateCache(wallet);
$rootScope.$emit('Local/TxAction', wallet.id);
});
return cb(null, signedTxp);
}