Merge pull request #383 from JDonadio/fix/edit-note

Fix edit memo
This commit is contained in:
Matias Alejo Garcia 2016-10-12 11:50:10 -03:00 committed by GitHub
commit 99efe06343
4 changed files with 29 additions and 19 deletions

View File

@ -24,7 +24,7 @@
"angular-mocks": "1.4.10", "angular-mocks": "1.4.10",
"bezier-easing": "^2.0.3", "bezier-easing": "^2.0.3",
"bhttp": "^1.2.1", "bhttp": "^1.2.1",
"bitcore-wallet-client": "4.2.1", "bitcore-wallet-client": "4.3.1",
"bower": "^1.7.9", "bower": "^1.7.9",
"chai": "^3.5.0", "chai": "^3.5.0",
"cordova": "5.4.1", "cordova": "5.4.1",

View File

@ -27,18 +27,28 @@ angular.module('copayApp.controllers').controller('txDetailsController', functio
}; };
function updateMemo() { function updateMemo() {
wallet.getTxNote({ walletService.getTxNote(wallet, $scope.btx.txid, function(err, note) {
txid: $scope.btx.txid if (err) {
}, function(err, note) { $log.warn('Could not fetch transaction note ' + err);
if (err || !note) {
$log.debug(gettextCatalog.getString('Could not fetch transaction note'));
return; return;
} }
$scope.note = note;
if (!note) return;
$scope.btx.note = note;
walletService.getTx(wallet, $scope.btx.txid, function(err, tx) {
if (err) {
$log.error(err);
return;
}
tx.note = note;
$timeout(function() { $timeout(function() {
$scope.$apply(); $scope.$apply();
}); });
}); });
});
}; };
function initActionList() { function initActionList() {
@ -91,19 +101,13 @@ angular.module('copayApp.controllers').controller('txDetailsController', functio
body: text body: text
}; };
wallet.editTxNote(args, function(err) { walletService.editTxNote(wallet, args, function(err, res) {
if (err) { if (err) {
$log.debug('Could not save tx comment'); $log.debug('Could not save tx comment ' + err);
return; return;
} }
// This is only to refresh the current screen data // This is only to refresh the current screen data
$scope.btx.note = null; updateMemo();
if (args.body) {
$scope.btx.note = {};
$scope.btx.note.body = text;
$scope.btx.note.editedByName = wallet.credentials.copayerName;
$scope.btx.note.editedOn = Math.floor(Date.now() / 1000);
}
$scope.btx.searcheableString = null; $scope.btx.searcheableString = null;
$timeout(function() { $timeout(function() {
$scope.$apply(); $scope.$apply();

View File

@ -512,6 +512,12 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
}); });
}; };
root.editTxNote = function(wallet, args, cb) {
wallet.editTxNote(args, function(err, res) {
return cb(err, res);
});
};
root.getTxp = function(wallet, txpid, cb) { root.getTxp = function(wallet, txpid, cb) {
wallet.getTx(txpid, function(err, txp) { wallet.getTx(txpid, function(err, txp) {
if (err) return cb(err); if (err) return cb(err);

View File

@ -130,7 +130,7 @@
</div> </div>
<div class="card list" ng-show="txHistory[0]"> <div class="card list" ng-show="txHistory[0]">
<div class="item" ng-repeat="btx in txHistory track by btx.txid" ng-click="openTxModal(btx)"> <div class="item" ng-repeat="btx in txHistory track by $index" ng-click="openTxModal(btx)">
<span class="item-note text-right"> <span class="item-note text-right">
<span class="size-16" ng-class="{'text-bold': btx.recent}"> <span class="size-16" ng-class="{'text-bold': btx.recent}">
<span ng-if="btx.action == 'received'">+</span> <span ng-if="btx.action == 'received'">+</span>