From ea7948f4209b365980f2dbf0f246f53efe6acceb Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Wed, 13 Aug 2014 21:06:57 -0400 Subject: [PATCH] paypro: better error display on no unspent outputs. --- js/controllers/send.js | 16 ++++++++++++++++ views/send.html | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/js/controllers/send.js b/js/controllers/send.js index 1bbbf0270..1417002c0 100644 --- a/js/controllers/send.js +++ b/js/controllers/send.js @@ -430,13 +430,29 @@ angular.module('copayApp.controllers').controller('SendController', if (err) { scope.sendForm.address.$isValid = false; + if (err.amount) { scope.sendForm.amount.$setViewValue(+err.amount / config.unitToSatoshi); scope.sendForm.amount.$render(); scope.sendForm.amount.$isValid = false; scope.notEnoughAmount = true; + $rootScope.merchantError = true; + var lastAddr = scope.sendForm.address.$viewValue; + var unregister = scope.$watch('address', function() { + if (scope.sendForm.address.$viewValue !== lastAddr) { + delete $rootScope.merchantError; + scope.sendForm.amount.$setViewValue(''); + scope.sendForm.amount.$render(); + unregister(); + if ($rootScope.$$phase !== '$apply' && $rootScope.$$phase !== '$digest') { + $rootScope.$apply(); + } + } + }); } + notification.error('Error', err.message || 'Bad payment server.'); + if ($rootScope.$$phase !== '$apply' && $rootScope.$$phase !== '$digest') { $rootScope.$apply(); } diff --git a/views/send.html b/views/send.html index 9861deead..05328c8e3 100644 --- a/views/send.html +++ b/views/send.html @@ -65,7 +65,7 @@