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',
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.bitpayCardEnabled = true; // TODO
$scope.openTxpModal = txpModalService.open;
@ -17,22 +18,33 @@ angular.module('copayApp.controllers').controller('tabHomeController',
});
$scope.openNotificationModal = function(n) {
wallet = profileService.getWallet(n.walletId);
if (n.txid) {
openTxModal(n);
} else {
var txp = lodash.find($scope.txps, {
id: n.txpId
});
if (txp) txpModalService.open(txp);
else {
$log.warn('No txp found');
return popupService.showAlert(null, gettextCatalog.getString('Transaction not found'));
if (txp) {
txpModalService.open(txp);
} else {
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 wallet = profileService.getWallet(n.walletId);
wallet = profileService.getWallet(n.walletId);
ongoingProcess.set('loadingTxInfo', true);
walletService.getTx(wallet, n.txid, function(err, tx) {

View file

@ -1,6 +1,6 @@
'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 = {};
@ -11,11 +11,12 @@ angular.module('copayApp.services').factory('txpModalService', function(configSe
root.open = function(tx) {
var wallet = tx.wallet ? tx.wallet : profileService.getWallet(tx.walletId);
var config = configService.getSync().wallet;
var scope = $rootScope.$new(true);
scope.tx = tx;
scope.wallet = tx.wallet;
scope.copayers = tx.wallet ? tx.wallet.copayers : null;
scope.wallet = wallet;
scope.copayers = wallet ? wallet.copayers : null;
scope.isGlidera = glideraActive;
scope.currentSpendUnconfirmed = config.spendUnconfirmed;
// 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) {
var tx;