diff --git a/src/js/controllers/modals/txDetails.js b/src/js/controllers/modals/txDetails.js index e4df94c27..d4e227aec 100644 --- a/src/js/controllers/modals/txDetails.js +++ b/src/js/controllers/modals/txDetails.js @@ -1,6 +1,6 @@ 'use strict'; -angular.module('copayApp.controllers').controller('txDetailsController', function($rootScope, $log, $scope, $filter, $ionicPopup, gettextCatalog, profileService, configService) { +angular.module('copayApp.controllers').controller('txDetailsController', function($rootScope, $log, $scope, $filter, $ionicPopup, gettextCatalog, profileService, configService, lodash) { var self = $scope.self; var fc = profileService.focusedClient; @@ -14,7 +14,7 @@ angular.module('copayApp.controllers').controller('txDetailsController', functio $scope.isShared = fc.credentials.n > 1; $scope.showCommentPopup = function() { $scope.data = { - comment: $scope.btx.note ? $scope.btx.note.body : '', + comment: $scope.btx.note ? $scope.btx.note.body : '', }; var commentPopup = $ionicPopup.show({ @@ -28,19 +28,27 @@ angular.module('copayApp.controllers').controller('txDetailsController', functio $scope.commentPopupSave = function() { $log.debug('Saving note'); - fc.editTxNote({ + var args = { txid: $scope.btx.txid, - body: $scope.data.comment, - }, function(err) { + }; + + if (!lodash.isEmpty($scope.data.comment)) { + args.body = $scope.data.comment; + }; + + fc.editTxNote(args, function(err) { if (err) { $log.debug('Could not save tx comment'); return; } // This is only to refresh the current screen data - $scope.btx.note = {}; - $scope.btx.note.body = $scope.data.comment; - $scope.btx.note.editedByName = fc.credentials.copayerName; - $scope.btx.note.editedOn = Math.floor(Date.now() / 1000); + $scope.btx.note = null; + if (args.body) { + $scope.btx.note = {}; + $scope.btx.note.body = $scope.data.comment; + $scope.btx.note.editedByName = fc.credentials.copayerName; + $scope.btx.note.editedOn = Math.floor(Date.now() / 1000); + } $scope.btx.searcheableString = null; commentPopup.close(); });