From 8f241b2efcca5e30fae12ac15d75c38454fab94c Mon Sep 17 00:00:00 2001 From: JDonadio Date: Fri, 10 Feb 2017 12:18:35 -0300 Subject: [PATCH 1/3] ref addresses view --- src/js/controllers/addresses.js | 63 ++++++++++++++++++------------- src/js/services/onGoingProcess.js | 1 - src/sass/shame.scss | 2 +- www/views/activity.html | 2 +- www/views/addresses.html | 31 +++++++++++---- www/views/allAddresses.html | 11 ++++++ www/views/proposals.html | 2 +- www/views/walletDetails.html | 2 +- 8 files changed, 75 insertions(+), 39 deletions(-) diff --git a/src/js/controllers/addresses.js b/src/js/controllers/addresses.js index 981371b16..1215ed009 100644 --- a/src/js/controllers/addresses.js +++ b/src/js/controllers/addresses.js @@ -1,32 +1,43 @@ 'use strict'; -angular.module('copayApp.controllers').controller('addressesController', function($scope, $stateParams, $state, $timeout, $ionicHistory, $ionicScrollDelegate, configService, popupService, gettextCatalog, ongoingProcess, lodash, profileService, walletService, bwcError, platformInfo) { +angular.module('copayApp.controllers').controller('addressesController', function($scope, $log, $stateParams, $state, $timeout, $ionicHistory, $ionicScrollDelegate, configService, popupService, gettextCatalog, lodash, profileService, walletService, bwcError, platformInfo) { var UNUSED_ADDRESS_LIMIT = 5; var BALANCE_ADDRESS_LIMIT = 5; - var config; - var unitName; - var unitToSatoshi; - var satToUnit; - var unitDecimals; - var withBalance; - $scope.showInfo = false; - $scope.showMore = false; - $scope.allAddressesView = false; + var config = configService.getSync().wallet.settings; + var unitName = config.unitName; + var unitToSatoshi = config.unitToSatoshi; + var satToUnit = 1 / unitToSatoshi; + var unitDecimals = config.unitDecimals; + var withBalance, cachedWallet; + $scope.isCordova = platformInfo.isCordova; $scope.wallet = profileService.getWallet($stateParams.walletId); - function init() { - ongoingProcess.set('gettingAddresses', true); + function resetValues() { + $scope.loading = false; + $scope.showInfo = false; + $scope.showMore = false; + $scope.allAddressesView = false; + $scope.latestUnused = $scope.latestWithBalance = null; + $scope.viewAll = { + value: false + }; + }; + + $scope.init = function() { + resetValues(); + $scope.loading = true; + walletService.getMainAddresses($scope.wallet, {}, function(err, addresses) { if (err) { - ongoingProcess.set('gettingAddresses', false); + $scope.loading = false; return popupService.showAlert(bwcError.msg(err, gettextCatalog.getString('Could not update wallet'))); } var allAddresses = addresses; walletService.getBalance($scope.wallet, {}, function(err, resp) { - ongoingProcess.set('gettingAddresses', false); + $scope.loading = false; if (err) { return popupService.showAlert(bwcError.msg(err, gettextCatalog.getString('Could not update wallet'))); } @@ -51,6 +62,10 @@ angular.module('copayApp.controllers').controller('addressesController', functio value: $scope.noBalance.length > UNUSED_ADDRESS_LIMIT || withBalance.length > BALANCE_ADDRESS_LIMIT }; $scope.allAddresses = $scope.noBalance.concat(withBalance); + + cachedWallet = $scope.wallet.id; + $log.debug('Addresses cached for Wallet:', cachedWallet); + $ionicScrollDelegate.resize(); $scope.$digest(); }); }); @@ -163,20 +178,14 @@ angular.module('copayApp.controllers').controller('addressesController', functio }); }; + function isCachedWallet(walletId) { + if (cachedWallet && cachedWallet == walletId) return true; + else return false; + }; + $scope.$on("$ionicView.beforeEnter", function(event, data) { $scope.allAddressesView = data.stateName == 'tabs.receive.allAddresses' ? true : false; - $timeout(function() { - $scope.$apply(); - }); - }); - - $scope.$on("$ionicView.afterEnter", function(event, data) { - config = configService.getSync().wallet.settings; - unitToSatoshi = config.unitToSatoshi; - satToUnit = 1 / unitToSatoshi; - unitName = config.unitName; - unitDecimals = config.unitDecimals; - - if (!$scope.allAddresses || $scope.allAddresses.length < 0) init(); + if (!isCachedWallet($stateParams.walletId)) $scope.init(); + else $log.debug('Addresses cached for Wallet:', $stateParams.walletId); }); }); diff --git a/src/js/services/onGoingProcess.js b/src/js/services/onGoingProcess.js index 48a83abf7..e8bda0082 100644 --- a/src/js/services/onGoingProcess.js +++ b/src/js/services/onGoingProcess.js @@ -35,7 +35,6 @@ angular.module('copayApp.services').factory('ongoingProcess', function($log, $ti 'loadingTxInfo': gettext('Loading transaction info...'), 'sendingFeedback': gettext('Sending feedback...'), 'generatingNewAddress': gettext('Generating new address...'), - 'gettingAddresses': gettext('Getting addresses...'), 'sendingByEmail': gettext('Preparing addresses...'), 'sending2faCode': gettext('Sending 2FA code...'), 'buyingBitcoin': gettext('Buying Bitcoin...'), diff --git a/src/sass/shame.scss b/src/sass/shame.scss index 514d04029..3b7121c2f 100644 --- a/src/sass/shame.scss +++ b/src/sass/shame.scss @@ -136,7 +136,7 @@ input[type=number] { white-space: nowrap; } -.updatingHistory { +.updating { div { text-align: center; } diff --git a/www/views/activity.html b/www/views/activity.html index 720ffb4e3..3d9f94d84 100644 --- a/www/views/activity.html +++ b/www/views/activity.html @@ -8,7 +8,7 @@ -
+
Updating... Please stand by
diff --git a/www/views/addresses.html b/www/views/addresses.html index 07596d3fa..cafa1bf42 100644 --- a/www/views/addresses.html +++ b/www/views/addresses.html @@ -3,6 +3,11 @@ {{'Wallet Addresses' | translate}} + + + @@ -26,23 +31,35 @@
+
+ Scan addresses for funds +
Request Specific amount
-
+
View All Addresses
-
- Scan addresses for funds -
-
- Unused Addresses - + +
+
+ +
+
+
+ Loading addresses... +
+
+
+ Unused Addresses + +
+
Unused Addresses Limit

The maximum number of consecutive unused addresses (20) has been reached. When one of your unused addresses receives a payment, a new address will be generated and shown in your Receive tab. Read more

diff --git a/www/views/allAddresses.html b/www/views/allAddresses.html index 8f7a1f345..5151964ec 100644 --- a/www/views/allAddresses.html +++ b/www/views/allAddresses.html @@ -9,6 +9,17 @@
+
+
+ +
+
+
+ Loading addresses... +
+
+
+
Send addresses by email diff --git a/www/views/proposals.html b/www/views/proposals.html index 1cbbb8e47..14b8348c9 100644 --- a/www/views/proposals.html +++ b/www/views/proposals.html @@ -9,7 +9,7 @@ -
+
Updating pending proposals. Please stand by
diff --git a/www/views/walletDetails.html b/www/views/walletDetails.html index bbcf28774..105d4be74 100644 --- a/www/views/walletDetails.html +++ b/www/views/walletDetails.html @@ -200,7 +200,7 @@
-
+
From 7a1676868f5c22578b990dda55182c37158f4a8d Mon Sep 17 00:00:00 2001 From: JDonadio Date: Fri, 10 Feb 2017 13:35:49 -0300 Subject: [PATCH 2/3] load after enter --- src/js/controllers/addresses.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/js/controllers/addresses.js b/src/js/controllers/addresses.js index 1215ed009..cc5a2b359 100644 --- a/src/js/controllers/addresses.js +++ b/src/js/controllers/addresses.js @@ -183,7 +183,7 @@ angular.module('copayApp.controllers').controller('addressesController', functio else return false; }; - $scope.$on("$ionicView.beforeEnter", function(event, data) { + $scope.$on("$ionicView.afterEnter", function(event, data) { $scope.allAddressesView = data.stateName == 'tabs.receive.allAddresses' ? true : false; if (!isCachedWallet($stateParams.walletId)) $scope.init(); else $log.debug('Addresses cached for Wallet:', $stateParams.walletId); From f42778ea94362c1bff29df8ac56189b6a696fcf6 Mon Sep 17 00:00:00 2001 From: JDonadio Date: Fri, 10 Feb 2017 13:39:49 -0300 Subject: [PATCH 3/3] remove hardcoded app name - fix missing service --- src/js/controllers/addresses.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/js/controllers/addresses.js b/src/js/controllers/addresses.js index cc5a2b359..4ea969be2 100644 --- a/src/js/controllers/addresses.js +++ b/src/js/controllers/addresses.js @@ -1,6 +1,6 @@ 'use strict'; -angular.module('copayApp.controllers').controller('addressesController', function($scope, $log, $stateParams, $state, $timeout, $ionicHistory, $ionicScrollDelegate, configService, popupService, gettextCatalog, lodash, profileService, walletService, bwcError, platformInfo) { +angular.module('copayApp.controllers').controller('addressesController', function($scope, $log, $stateParams, $state, $timeout, $ionicHistory, $ionicScrollDelegate, configService, popupService, gettextCatalog, ongoingProcess, lodash, profileService, walletService, bwcError, platformInfo, appConfigService) { var UNUSED_ADDRESS_LIMIT = 5; var BALANCE_ADDRESS_LIMIT = 5; var config = configService.getSync().wallet.settings; @@ -156,16 +156,17 @@ angular.module('copayApp.controllers').controller('addressesController', functio ongoingProcess.set('sendingByEmail', true); $timeout(function() { - var body = 'Copay Wallet "' + $scope.wallet.name + '" Addresses\n Only Main Addresses are shown.\n\n'; + var appName = appConfigService.nameCase; + var body = appName + ' Wallet "' + $scope.wallet.name + '" Addresses\n Only Main Addresses are shown.\n\n'; body += "\n"; body += $scope.allAddresses.map(function(v) { - return ('* ' + v.address + ' ' + 'xpub' + v.path.substring(1) + ' ' + formatDate(v.createdOn)); + return ('* ' + v.address + ' xpub' + v.path.substring(1) + ' ' + formatDate(v.createdOn)); }).join("\n"); ongoingProcess.set('sendingByEmail', false); window.plugins.socialsharing.shareViaEmail( body, - 'Copay Addresses', + appName + ' Addresses', null, // TO: must be null or an array null, // CC: must be null or an array null, // BCC: must be null or an array