open a rejected txp

This commit is contained in:
Javier 2016-09-21 16:04:25 -03:00
commit c12f33b1d9
3 changed files with 28 additions and 8 deletions

View file

@ -2,6 +2,7 @@
angular.module('copayApp.controllers').controller('tabHomeController', angular.module('copayApp.controllers').controller('tabHomeController',
function($rootScope, $timeout, $scope, $state, $stateParams, $ionicModal, $ionicScrollDelegate, gettextCatalog, lodash, popupService, ongoingProcess, profileService, walletService, configService, $log, platformInfo, storageService, txpModalService, $window) { function($rootScope, $timeout, $scope, $state, $stateParams, $ionicModal, $ionicScrollDelegate, gettextCatalog, lodash, popupService, ongoingProcess, profileService, walletService, configService, $log, platformInfo, storageService, txpModalService, $window) {
var wallet;
$scope.externalServices = {}; $scope.externalServices = {};
$scope.bitpayCardEnabled = true; // TODO $scope.bitpayCardEnabled = true; // TODO
$scope.openTxpModal = txpModalService.open; $scope.openTxpModal = txpModalService.open;
@ -17,22 +18,33 @@ angular.module('copayApp.controllers').controller('tabHomeController',
}); });
$scope.openNotificationModal = function(n) { $scope.openNotificationModal = function(n) {
wallet = profileService.getWallet(n.walletId);
if (n.txid) { if (n.txid) {
openTxModal(n); openTxModal(n);
} else { } else {
var txp = lodash.find($scope.txps, { var txp = lodash.find($scope.txps, {
id: n.txpId id: n.txpId
}); });
if (txp) txpModalService.open(txp); if (txp) {
else { txpModalService.open(txp);
$log.warn('No txp found'); } else {
return popupService.showAlert(null, gettextCatalog.getString('Transaction not found')); ongoingProcess.set('loadingTxInfo', true);
walletService.getTxp(wallet, n.txpId, function(err, txp) {
var _txp = txp;
ongoingProcess.set('loadingTxInfo', false);
if (err) {
$log.warn('No txp found');
return popupService.showAlert(null, gettextCatalog.getString('Transaction not found'));
}
txpModalService.open(_txp);
});
} }
} }
}; };
var openTxModal = function(n) { var openTxModal = function(n) {
var wallet = profileService.getWallet(n.walletId); wallet = profileService.getWallet(n.walletId);
ongoingProcess.set('loadingTxInfo', true); ongoingProcess.set('loadingTxInfo', true);
walletService.getTx(wallet, n.txid, function(err, tx) { walletService.getTx(wallet, n.txid, function(err, tx) {

View file

@ -1,6 +1,6 @@
'use strict'; 'use strict';
angular.module('copayApp.services').factory('txpModalService', function(configService, $rootScope, $ionicModal) { angular.module('copayApp.services').factory('txpModalService', function(configService, profileService, $rootScope, $ionicModal) {
var root = {}; var root = {};
@ -11,11 +11,12 @@ angular.module('copayApp.services').factory('txpModalService', function(configSe
root.open = function(tx) { root.open = function(tx) {
var wallet = tx.wallet ? tx.wallet : profileService.getWallet(tx.walletId);
var config = configService.getSync().wallet; var config = configService.getSync().wallet;
var scope = $rootScope.$new(true); var scope = $rootScope.$new(true);
scope.tx = tx; scope.tx = tx;
scope.wallet = tx.wallet; scope.wallet = wallet;
scope.copayers = tx.wallet ? tx.wallet.copayers : null; scope.copayers = wallet ? wallet.copayers : null;
scope.isGlidera = glideraActive; scope.isGlidera = glideraActive;
scope.currentSpendUnconfirmed = config.spendUnconfirmed; scope.currentSpendUnconfirmed = config.spendUnconfirmed;
// scope.tx.hasMultiplesOutputs = true; // Uncomment to test multiple outputs // scope.tx.hasMultiplesOutputs = true; // Uncomment to test multiple outputs

View file

@ -502,6 +502,13 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
}); });
}; };
root.getTxp = function(wallet, txpid, cb) {
wallet.getTx(txpid, function(err, txp) {
if (err) return cb(err);
return cb(null, txp);
});
};
root.getTx = function(wallet, txid, cb) { root.getTx = function(wallet, txid, cb) {
var tx; var tx;