diff --git a/src/js/controllers/activity.js b/src/js/controllers/activity.js index b0e182c6f..dbf2f5ada 100644 --- a/src/js/controllers/activity.js +++ b/src/js/controllers/activity.js @@ -66,7 +66,10 @@ angular.module('copayApp.controllers').controller('activityController', $scope.wallet = wallet; $scope.btx = lodash.cloneDeep(tx); - $state.go('tabs.wallet.tx-details', {tx: $scope.btx, wallet: $scope.wallet}); + $state.transitionTo('tabs.wallet.tx-details', { + txid: $scope.btx.txid, + walletId: $scope.walletId + }); walletService.getTxNote(wallet, n.txid, function(err, note) { if (err) $log.warn('Could not fetch transaction note: ' + err); diff --git a/src/js/controllers/modals/txDetails.js b/src/js/controllers/modals/txDetails.js index 89f5e19ac..ea2cb431a 100644 --- a/src/js/controllers/modals/txDetails.js +++ b/src/js/controllers/modals/txDetails.js @@ -1,34 +1,39 @@ 'use strict'; -angular.module('copayApp.controllers').controller('txDetailsController', function($log, $timeout, $scope, $filter, $stateParams, ongoingProcess, walletService, lodash, gettextCatalog, profileService, configService, txFormatService, externalLinkService, popupService) { +angular.module('copayApp.controllers').controller('txDetailsController', function($log, $timeout, $ionicHistory, $scope, $filter, $stateParams, ongoingProcess, walletService, lodash, gettextCatalog, profileService, configService, txFormatService, externalLinkService, popupService) { var config = configService.getSync(); var configWallet = config.wallet; var walletSettings = configWallet.settings; - var wallet; + var wallet = profileService.getWallet($stateParams.walletId); + + $scope.wallet = wallet; $scope.title = gettextCatalog.getString('Transaction'); - $scope.btx = $stateParams.tx; - $scope.wallet = $stateParams.wallet; - $scope.init = function() { - wallet = $scope.wallet; $scope.alternativeIsoCode = walletSettings.alternativeIsoCode; $scope.color = wallet.color; $scope.copayerId = wallet.credentials.copayerId; $scope.isShared = wallet.credentials.n > 1; - $scope.btx.feeLevel = walletSettings.feeLevel; + walletService.getTx(wallet, $stateParams.txid, function(err, tx) { + if (err) { + $log.warn('Could not get tx'); + $ionicHistory.goBack(); + return; + } + $scope.btx = tx; + $scope.btx.feeLevel = walletSettings.feeLevel; + if ($scope.btx.action != 'invalid') { + if ($scope.btx.action == 'sent') $scope.title = gettextCatalog.getString('Sent Funds'); + if ($scope.btx.action == 'received') $scope.title = gettextCatalog.getString('Received Funds'); + if ($scope.btx.action == 'moved') $scope.title = gettextCatalog.getString('Moved Funds'); + } - if ($scope.btx.action != 'invalid') { - if ($scope.btx.action == 'sent') $scope.title = gettextCatalog.getString('Sent Funds'); - if ($scope.btx.action == 'received') $scope.title = gettextCatalog.getString('Received Funds'); - if ($scope.btx.action == 'moved') $scope.title = gettextCatalog.getString('Moved Funds'); - } + $scope.displayAmount = getDisplayAmount($scope.btx.amountStr); + $scope.displayUnit = getDisplayUnit($scope.btx.amountStr); - $scope.displayAmount = getDisplayAmount($scope.btx.amountStr); - $scope.displayUnit = getDisplayUnit($scope.btx.amountStr); - - updateMemo(); - initActionList(); + updateMemo(); + initActionList(); + }); }; function getDisplayAmount(amountStr) { @@ -99,7 +104,7 @@ angular.module('copayApp.controllers').controller('txDetailsController', functio $scope.showCommentPopup = function() { var opts = {}; - if($scope.btx.message) { + if ($scope.btx.message) { opts.defaultText = $scope.btx.message; } if ($scope.btx.note && $scope.btx.note.body) opts.defaultText = $scope.btx.note.body; diff --git a/src/js/controllers/tab-home.js b/src/js/controllers/tab-home.js index 61542dbd8..8d1f3963a 100644 --- a/src/js/controllers/tab-home.js +++ b/src/js/controllers/tab-home.js @@ -68,7 +68,10 @@ angular.module('copayApp.controllers').controller('tabHomeController', $scope.wallet = wallet; $scope.btx = lodash.cloneDeep(tx); - $state.go('tabs.wallet.tx-details', {tx: $scope.btx, wallet: $scope.wallet}); + $state.transitionTo('tabs.wallet.tx-details', { + txid: $scope.btx.txid, + walletId: $scope.walletId + }); walletService.getTxNote(wallet, n.txid, function(err, note) { if (err) $log.warn('Could not fetch transaction note: ' + err); diff --git a/src/js/controllers/walletDetails.js b/src/js/controllers/walletDetails.js index 221808210..6fd7a8b30 100644 --- a/src/js/controllers/walletDetails.js +++ b/src/js/controllers/walletDetails.js @@ -92,7 +92,10 @@ angular.module('copayApp.controllers').controller('walletDetailsController', fun $scope.openTxModal = function(btx) { $scope.btx = lodash.cloneDeep(btx); $scope.walletId = $scope.wallet.id; - $state.go('tabs.wallet.tx-details', {tx: $scope.btx, wallet: $scope.wallet}); + $state.transitionTo('tabs.wallet.tx-details', { + txid: $scope.btx.txid, + walletId: $scope.walletId + }); }; $scope.recreate = function() { diff --git a/src/js/routes.js b/src/js/routes.js index ff96d1aa6..c09789ab2 100644 --- a/src/js/routes.js +++ b/src/js/routes.js @@ -178,16 +178,12 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr } }) .state('tabs.wallet.tx-details', { - url: '/:id', + url: '/tx-details/:txid', views: { 'tab-home@tabs': { controller: 'txDetailsController', templateUrl: 'views/modals/tx-details.html' } - }, - params: { - tx: null, - wallet: null } }) @@ -859,7 +855,7 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr * */ - .state('tabs.bitpayCardIntro', { + .state('tabs.bitpayCardIntro', { url: '/bitpay-card-intro/:secret/:email/:otp', views: { 'tab-home@tabs': {