diff --git a/src/js/controllers/index.js b/src/js/controllers/index.js index fd920173d..1e8773198 100644 --- a/src/js/controllers/index.js +++ b/src/js/controllers/index.js @@ -757,8 +757,7 @@ angular.module('copayApp.controllers').controller('indexController', function($r var confirmedTxs = self.removeAndMarkSoftConfirmedTx(txsFromLocal); var endingTxid = confirmedTxs[0] ? confirmedTxs[0].txid : null; - var endingTs = confirmedTxs[0] ? confirmedTxs[0].ts : null; -console.log('[index.js.760:endingTs:]',endingTs); //TODO + var endingTs = confirmedTxs[0] ? confirmedTxs[0].time : null; // First update @@ -813,24 +812,52 @@ console.log('[index.js.760:endingTs:]',endingTs); //TODO var newHistory = lodash.uniq(lodash.compact(txs.concat(confirmedTxs)), function(x) { return x.txid; }); - var historyToSave = JSON.stringify(newHistory); - lodash.each(txs, function(tx) { - tx.recent = true; - }) - $log.debug('Tx History synced. Total Txs: ' + newHistory.length); + function updateNotes(cb2) { + if (!endingTs) return cb2(); - // Final update - if (walletId == profileService.focusedClient.credentials.walletId) { - self.completeHistory = newHistory; - self.setCompactTxHistory(); + $log.debug('Syncing notes from: ' + endingTs); + client.getTxNotes({ + minTs: endingTs + }, function(err, notes) { + if (err) { + $log.warn(err); + return cb2(); + }; + lodash.each(notes, function(note) { + $log.debug('Note for ' + note.txid); + lodash.each(newHistory, function(tx) { + if (tx.txid == note.txid) { + $log.debug('...updating note for ' + note.txid); + tx.note = note; + } + }); + }); + return cb2(); + }); } - return storageService.setTxHistory(historyToSave, walletId, function() { - $log.debug('Tx History saved.'); + updateNotes(function() { + var historyToSave = JSON.stringify(newHistory); - return cb(); + lodash.each(txs, function(tx) { + tx.recent = true; + }) + + $log.debug('Tx History synced. Total Txs: ' + newHistory.length); + + // Final update + if (walletId == profileService.focusedClient.credentials.walletId) { + self.completeHistory = newHistory; + self.setCompactTxHistory(); + } + + return storageService.setTxHistory(historyToSave, walletId, function() { + $log.debug('Tx History saved.'); + + return cb(); + }); }); }); }); diff --git a/src/js/controllers/modals/txDetails.js b/src/js/controllers/modals/txDetails.js index 17081ca2f..cb9b40130 100644 --- a/src/js/controllers/modals/txDetails.js +++ b/src/js/controllers/modals/txDetails.js @@ -12,22 +12,6 @@ angular.module('copayApp.controllers').controller('txDetailsController', functio $scope.color = fc.backgroundColor; $scope.copayerId = fc.credentials.copayerId; $scope.isShared = fc.credentials.n > 1; - -console.log('[txDetails.js.16:btx:]',$scope.btx); //TODO - // if ($scope.btx.txid) { - // fc.getTxNote({ - // txid: $scope.btx.txid - // }, function(err, note) { - // if (err || !note) { - // $log.debug(gettextCatalog.getString('Could not fetch transaction note')); - // return; - // } - // $scope.comment = note.body; - // $scope.editedBy = gettextCatalog.getString('Edited by') + ' ' + note.editedByName; - // $scope.createdOn = note.createdOn; - // }); - // } - // $scope.showCommentPopup = function() { $scope.data = { comment: ''