diff --git a/public/views/activity.html b/public/views/activity.html index 8a1738373..c020fa25f 100644 --- a/public/views/activity.html +++ b/public/views/activity.html @@ -19,7 +19,7 @@
-
+
diff --git a/public/views/modals/tx-details.html b/public/views/modals/tx-details.html index 79e7f5be9..e1e2c3640 100644 --- a/public/views/modals/tx-details.html +++ b/public/views/modals/tx-details.html @@ -9,7 +9,7 @@ -
+
@@ -53,7 +53,7 @@
-
+
diff --git a/public/views/tab-home.html b/public/views/tab-home.html index 7be004eab..c870f2088 100644 --- a/public/views/tab-home.html +++ b/public/views/tab-home.html @@ -30,7 +30,7 @@ {{txpsN}} - +
diff --git a/src/js/controllers/activity.js b/src/js/controllers/activity.js index 6205357c5..a55eb40f0 100644 --- a/src/js/controllers/activity.js +++ b/src/js/controllers/activity.js @@ -1,10 +1,7 @@ 'use strict'; angular.module('copayApp.controllers').controller('activityController', - function($rootScope, $timeout, $scope, $state, lodash, profileService, walletService, configService, txFormatService, $ionicModal, $log, platformInfo) { - var self = this; - - + function($timeout, $scope, $log, $ionicModal, lodash, profileService, walletService, ongoingProcess, popupService, gettextCatalog) { $scope.init = function() { $scope.fetchingNotifications = true; profileService.getNotifications(50, function(err, n) { @@ -19,4 +16,32 @@ angular.module('copayApp.controllers').controller('activityController', }, 1); }); } + + $scope.openTxModal = function(n) { + var wallet = profileService.getWallet(n.walletId); + + ongoingProcess.set('loadingTxInfo', true); + walletService.getTx(wallet, n.txid, function(err, tx) { + ongoingProcess.set('loadingTxInfo', false); + + if (err) { + $log.error(err); + return popupService.showAlert(gettextCatalog.getString('Error'), err); + } + + if (!tx) { + $log.warn('No tx found'); + return popupService.showAlert(gettextCatalog.getString('Transaction not found'), null); + } + + $scope.wallet = wallet; + $scope.btx = lodash.cloneDeep(tx); + $ionicModal.fromTemplateUrl('views/modals/tx-details.html', { + scope: $scope + }).then(function(modal) { + $scope.txDetailsModal = modal; + $scope.txDetailsModal.show(); + }); + }); + }; }); diff --git a/src/js/controllers/modals/txDetails.js b/src/js/controllers/modals/txDetails.js index b7c142edb..dcd14c962 100644 --- a/src/js/controllers/modals/txDetails.js +++ b/src/js/controllers/modals/txDetails.js @@ -1,64 +1,32 @@ 'use strict'; angular.module('copayApp.controllers').controller('txDetailsController', function($log, $timeout, $scope, $filter, $stateParams, ongoingProcess, walletService, lodash, gettextCatalog, profileService, configService, txFormatService, externalLinkService, popupService) { - var self = $scope.self; - var wallet = profileService.getWallet($stateParams.walletId || $scope.walletId); var config = configService.getSync(); var configWallet = config.wallet; var walletSettings = configWallet.settings; + var wallet; $scope.title = gettextCatalog.getString('Transaction'); - $scope.loadingTxInfo = false; $scope.init = function() { - $scope.loadingTxInfo = true; - ongoingProcess.set('loadingTxInfo', true); - findTx($scope.txid, function(err, tx) { - ongoingProcess.set('loadingTxInfo', false); - $scope.loadingTxInfo = false; - if (err) { - $log.error(err); - popupService.showAlert(gettextCatalog.getString('Error'), err); - return $scope.cancel(); - } + 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; - if (!tx) { - $log.warn('No tx found'); - popupService.showAlert(gettextCatalog.getString('Transaction not found'), null); - return $scope.cancel(); - } + 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.btx = lodash.cloneDeep(tx); - $scope.alternativeIsoCode = walletSettings.alternativeIsoCode; - $scope.color = wallet.color; - $scope.copayerId = wallet.credentials.copayerId; - $scope.isShared = wallet.credentials.n > 1; - $scope.btx.feeLevel = walletSettings.feeLevel; + initActionList(); + getAlternativeAmount(); - 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'); - } - - initActionList(); - getAlternativeAmount(); - - $timeout(function() { - $scope.$apply(); - }, 10); - }); - }; - - function findTx(txid, cb) { - walletService.getTxHistory(wallet, {}, function(err, txHistory) { - if (err) return cb(err); - - var tx = lodash.find(txHistory, { - txid: txid - }); - - return cb(null, tx); - }); + $timeout(function() { + $scope.$apply(); + }, 100); }; function initActionList() { @@ -158,8 +126,5 @@ angular.module('copayApp.controllers').controller('txDetailsController', functio $scope.cancel = function() { $scope.txDetailsModal.hide(); - $timeout(function() { - $scope.txDetailsModal.remove(); - }, 10); }; }); diff --git a/src/js/controllers/tab-home.js b/src/js/controllers/tab-home.js index 605c67ee3..2acf9428c 100644 --- a/src/js/controllers/tab-home.js +++ b/src/js/controllers/tab-home.js @@ -1,7 +1,7 @@ 'use strict'; angular.module('copayApp.controllers').controller('tabHomeController', - function($rootScope, $timeout, $scope, $state, $stateParams, $ionicModal, $ionicScrollDelegate, lodash, 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) { $scope.externalServices = {}; $scope.bitpayCardEnabled = true; // TODO $scope.openTxpModal = txpModalService.open; @@ -17,13 +17,30 @@ angular.module('copayApp.controllers').controller('tabHomeController', }); $scope.openTxModal = function(n) { - $scope.txid = n.txid; - $scope.walletId = n.walletId; - $ionicModal.fromTemplateUrl('views/modals/tx-details.html', { - scope: $scope - }).then(function(modal) { - $scope.txDetailsModal = modal; - $scope.txDetailsModal.show(); + var wallet = profileService.getWallet(n.walletId); + + ongoingProcess.set('loadingTxInfo', true); + walletService.getTx(wallet, n.txid, function(err, tx) { + ongoingProcess.set('loadingTxInfo', false); + + if (err) { + $log.error(err); + return popupService.showAlert(gettextCatalog.getString('Error'), err); + } + + if (!tx) { + $log.warn('No tx found'); + return popupService.showAlert(gettextCatalog.getString('Transaction not found'), null); + } + + $scope.wallet = wallet; + $scope.btx = lodash.cloneDeep(tx); + $ionicModal.fromTemplateUrl('views/modals/tx-details.html', { + scope: $scope + }).then(function(modal) { + $scope.txDetailsModal = modal; + $scope.txDetailsModal.show(); + }); }); }; diff --git a/src/js/controllers/walletDetails.js b/src/js/controllers/walletDetails.js index f9a23f91c..9b1b63c41 100644 --- a/src/js/controllers/walletDetails.js +++ b/src/js/controllers/walletDetails.js @@ -131,18 +131,13 @@ angular.module('copayApp.controllers').controller('walletDetailsController', fun $scope.close = function() { $scope.searchModal.hide(); } - }; $scope.openTxModal = function(btx) { - var self = this; - $scope.btx = lodash.cloneDeep(btx); - $scope.self = self; - + $scope.walletId = wallet.id; $ionicModal.fromTemplateUrl('views/modals/tx-details.html', { - scope: $scope, - hideDelay: 500 + scope: $scope }).then(function(modal) { $scope.txDetailsModal = modal; $scope.txDetailsModal.show(); diff --git a/src/js/services/walletService.js b/src/js/services/walletService.js index d23c8b906..0af28637b 100644 --- a/src/js/services/walletService.js +++ b/src/js/services/walletService.js @@ -502,6 +502,17 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim }); }; + root.getTx = function(wallet, txid, cb) { + root.getTxHistory(wallet, {}, function(err, txHistory) { + if (err) return cb(err); + + var tx = lodash.find(txHistory, { + txid: txid + }); + + return cb(null, tx); + }); + }; root.getTxHistory = function(wallet, opts, cb) { opts = opts || {};