From 93d694d04822d3692a5a5bf40343dfda3deb102e Mon Sep 17 00:00:00 2001 From: Javier Date: Wed, 21 Sep 2016 17:28:59 -0300 Subject: [PATCH] sync memo --- public/views/modals/tx-details.html | 6 +++--- src/js/controllers/activity.js | 19 ++++++++++++------- src/js/controllers/modals/txDetails.js | 7 ------- src/js/controllers/tab-home.js | 19 ++++++++++++------- src/js/services/walletService.js | 9 +++++++++ 5 files changed, 36 insertions(+), 24 deletions(-) diff --git a/public/views/modals/tx-details.html b/public/views/modals/tx-details.html index 3365cbee9..797909be6 100644 --- a/public/views/modals/tx-details.html +++ b/public/views/modals/tx-details.html @@ -139,9 +139,9 @@
- Add Memo - Memo -
+ Add Memo + Memo +
{{btx.note.body}}
Edited by {{btx.note.editedByName}}, diff --git a/src/js/controllers/activity.js b/src/js/controllers/activity.js index 696730bff..ee1d50720 100644 --- a/src/js/controllers/activity.js +++ b/src/js/controllers/activity.js @@ -56,13 +56,18 @@ angular.module('copayApp.controllers').controller('activityController', return popupService.showAlert(null, gettextCatalog.getString('Transaction not found')); } - $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(); + walletService.getTxNote(wallet, n.txid, function(err, note) { + if (err) $log.debug(gettextCatalog.getString('Could not fetch transaction note')); + + $scope.wallet = wallet; + $scope.btx = lodash.cloneDeep(tx); + $scope.btx.note = note; + $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 d5b6f79d3..b4e45dae1 100644 --- a/src/js/controllers/modals/txDetails.js +++ b/src/js/controllers/modals/txDetails.js @@ -24,10 +24,6 @@ angular.module('copayApp.controllers').controller('txDetailsController', functio updateMemo(); initActionList(); getAlternativeAmount(); - - $timeout(function() { - $scope.$apply(); - }); }; function updateMemo() { @@ -38,7 +34,6 @@ angular.module('copayApp.controllers').controller('txDetailsController', functio $log.debug(gettextCatalog.getString('Could not fetch transaction note')); return; } - $scope.note = note; $timeout(function() { $scope.$apply(); @@ -108,7 +103,6 @@ angular.module('copayApp.controllers').controller('txDetailsController', functio $scope.btx.note.editedOn = Math.floor(Date.now() / 1000); } $scope.btx.searcheableString = null; - $timeout(function() { $scope.$apply(); }); @@ -132,7 +126,6 @@ angular.module('copayApp.controllers').controller('txDetailsController', functio $scope.rateDate = res.fetchedOn; $scope.rateStr = res.rate + ' ' + $scope.alternativeIsoCode; $scope.alternativeAmountStr = $filter('formatFiatAmount')(alternativeAmountBtc * res.rate) + ' ' + $scope.alternativeIsoCode; - $scope.$apply(); } }); }; diff --git a/src/js/controllers/tab-home.js b/src/js/controllers/tab-home.js index a9718c5ba..fe9b10423 100644 --- a/src/js/controllers/tab-home.js +++ b/src/js/controllers/tab-home.js @@ -60,13 +60,18 @@ angular.module('copayApp.controllers').controller('tabHomeController', return popupService.showAlert(null, gettextCatalog.getString('Transaction not found')); } - $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(); + walletService.getTxNote(wallet, n.txid, function(err, note) { + if (err) $log.debug(gettextCatalog.getString('Could not fetch transaction note')); + + $scope.wallet = wallet; + $scope.btx = lodash.cloneDeep(tx); + $scope.btx.note = note; + $ionicModal.fromTemplateUrl('views/modals/tx-details.html', { + 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 c6ec8bac5..0c9d00583 100644 --- a/src/js/services/walletService.js +++ b/src/js/services/walletService.js @@ -502,6 +502,15 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim }); }; + root.getTxNote = function(wallet, txid, cb) { + wallet.getTxNote({ + txid: txid + }, function(err, note) { + if (err || !note) return cb(true); + return cb(null, note); + }); + }; + root.getTxp = function(wallet, txpid, cb) { wallet.getTx(txpid, function(err, txp) { if (err) return cb(err);