diff --git a/src/js/controllers/modals/txDetails.js b/src/js/controllers/modals/txDetails.js index dcd14c962..dd2ed813c 100644 --- a/src/js/controllers/modals/txDetails.js +++ b/src/js/controllers/modals/txDetails.js @@ -21,12 +21,29 @@ angular.module('copayApp.controllers').controller('txDetailsController', functio if ($scope.btx.action == 'moved') $scope.title = gettextCatalog.getString('Moved Funds'); } + updateMemo(); initActionList(); getAlternativeAmount(); $timeout(function() { $scope.$apply(); - }, 100); + }); + }; + + function updateMemo() { + wallet.getTxNote({ + txid: $scope.btx.txid + }, function(err, note) { + if (err || !note) { + $log.debug(gettextCatalog.getString('Could not fetch transaction note')); + return; + } + + $scope.note = note; + $timeout(function() { + $scope.$apply(); + }); + }); }; function initActionList() { @@ -64,12 +81,12 @@ angular.module('copayApp.controllers').controller('txDetailsController', functio }; $scope.showCommentPopup = function() { - popupService.showPrompt(gettextCatalog.getString('Memo'), ' ', {}, function(res) { + popupService.showPrompt(gettextCatalog.getString('Memo'), ' ', {}, function(text) { $log.debug('Saving memo'); var args = { txid: $scope.btx.txid, - body: res + body: text }; wallet.editTxNote(args, function(err) { @@ -81,7 +98,7 @@ angular.module('copayApp.controllers').controller('txDetailsController', functio $scope.btx.note = null; if (args.body) { $scope.btx.note = {}; - $scope.btx.note.body = res; + $scope.btx.note.body = text; $scope.btx.note.editedByName = wallet.credentials.copayerName; $scope.btx.note.editedOn = Math.floor(Date.now() / 1000); } @@ -89,7 +106,7 @@ angular.module('copayApp.controllers').controller('txDetailsController', functio $timeout(function() { $scope.$apply(); - }, 200); + }); }); }); }; diff --git a/src/js/services/walletService.js b/src/js/services/walletService.js index 7f2f76e20..abeff92ee 100644 --- a/src/js/services/walletService.js +++ b/src/js/services/walletService.js @@ -503,23 +503,30 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim }; root.getTx = function(wallet, txid, cb) { + var tx; + if (wallet.completeHistory && wallet.completeHistory.isValid) { - var tx = lodash.find(wallet.completeHistory, { + tx = lodash.find(wallet.completeHistory, { txid: txid }); - return cb(null, tx); + finish(); } else { root.getTxHistory(wallet, {}, function(err, txHistory) { if (err) return cb(err); - var tx = lodash.find(txHistory, { + tx = lodash.find(txHistory, { txid: txid }); - return cb(null, tx); + finish(); }); } + + function finish() { + if (tx) return cb(null, tx); + else return cb(); + }; }; root.getTxHistory = function(wallet, opts, cb) {