From 034189e5042066b775d6e5252856ab7a50dff2ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20Baz=C3=A1n?= Date: Fri, 23 Sep 2016 15:42:09 -0300 Subject: [PATCH 1/5] add controller to backup route --- src/js/routes.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/js/routes.js b/src/js/routes.js index 3c4708d08..7bb6cb9de 100644 --- a/src/js/routes.js +++ b/src/js/routes.js @@ -628,7 +628,8 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr url: '/backup/:walletId/:fromOnboarding', views: { 'onboarding': { - templateUrl: 'views/backup.html' + templateUrl: 'views/backup.html', + controller: 'backupController' } } }) From 8d5fc83d40d76ef840282dbf6001ad67ab87d2b0 Mon Sep 17 00:00:00 2001 From: Javier Date: Fri, 23 Sep 2016 16:09:51 -0300 Subject: [PATCH 2/5] Fix update status --- src/js/services/walletService.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/js/services/walletService.js b/src/js/services/walletService.js index 0c9d00583..dcdf2ff02 100644 --- a/src/js/services/walletService.js +++ b/src/js/services/walletService.js @@ -265,7 +265,8 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim function _getStatus(initStatusHash, tries, cb) { if (isStatusCached() && !opts.force) { $log.debug('Wallet status cache hit:' + wallet.id); - + cacheStatus(wallet.cachedStatus); + processPendingTxps(wallet.cachedStatus); return cb(null, wallet.cachedStatus); }; From b370e610128a3d3c88df5beb1c19527b2b0450d9 Mon Sep 17 00:00:00 2001 From: Gustavo Maximiliano Cortez Date: Fri, 23 Sep 2016 17:10:34 -0300 Subject: [PATCH 3/5] Bug fixes. Split contacts and wallets from send --- public/views/amount.html | 3 ++- public/views/confirm.html | 3 ++- public/views/tab-send.html | 22 ++++++++++++++++++---- src/js/controllers/addressbookAdd.js | 2 +- src/js/controllers/amount.js | 12 ++++++------ src/js/controllers/confirm.js | 1 + src/js/controllers/tab-send.js | 3 +++ src/js/routes.js | 6 +++--- 8 files changed, 36 insertions(+), 16 deletions(-) diff --git a/public/views/amount.html b/public/views/amount.html index 10ee69f7e..207ca5c11 100644 --- a/public/views/amount.html +++ b/public/views/amount.html @@ -13,7 +13,8 @@
Recipient
- + + {{toName || toAddress}}
diff --git a/public/views/confirm.html b/public/views/confirm.html index 8be1797eb..721ef18c8 100644 --- a/public/views/confirm.html +++ b/public/views/confirm.html @@ -25,7 +25,8 @@
- + + To: {{toAddress}}

{{toName}}

diff --git a/public/views/tab-send.html b/public/views/tab-send.html index 861fa5892..e3fac9dcb 100644 --- a/public/views/tab-send.html +++ b/public/views/tab-send.html @@ -16,12 +16,26 @@
-
+
- Contacts & Wallets + Contacts
-
No Wallet - Contact
- + + + Add a Contact + + + + {{item.name}} + +
+ +
+
+ Transfer to Wallet +
+
No Wallet
+ {{item.name}} diff --git a/src/js/controllers/addressbookAdd.js b/src/js/controllers/addressbookAdd.js index 12d0305af..a33050197 100644 --- a/src/js/controllers/addressbookAdd.js +++ b/src/js/controllers/addressbookAdd.js @@ -31,7 +31,7 @@ angular.module('copayApp.controllers').controller('addressbookAddController', fu return; } if ($scope.fromSendTab) $scope.goHome(); - else $state.go('tabs.addressbook'); + else $ionicHistory.goBack(); }); }, 100); }; diff --git a/src/js/controllers/amount.js b/src/js/controllers/amount.js index 19a0c2b26..590fa55d4 100644 --- a/src/js/controllers/amount.js +++ b/src/js/controllers/amount.js @@ -10,10 +10,15 @@ angular.module('copayApp.controllers').controller('amountController', function($ var SMALL_FONT_SIZE_LIMIT = 13; var LENGTH_EXPRESSION_LIMIT = 19; + $scope.isWallet = $stateParams.isWallet; $scope.toAddress = $stateParams.toAddress; $scope.toName = $stateParams.toName; $scope.toEmail = $stateParams.toEmail; + $scope.$on('$ionicView.beforeLeave', function() { + angular.element($window).off('keydown'); + }); + $scope.$on("$ionicView.beforeEnter", function(event, data) { if (!$stateParams.toAddress) { @@ -24,7 +29,6 @@ angular.module('copayApp.controllers').controller('amountController', function($ var reNr = /^[1234567890\.]$/; var reOp = /^[\*\+\-\/]$/; - var disableKeys = angular.element($window).on('keydown', function(e) { if (e.which === 8) { // you can add others here inside brackets. e.preventDefault(); @@ -46,10 +50,6 @@ angular.module('copayApp.controllers').controller('amountController', function($ }); - $scope.$on('$destroy', function() { - angular.element($window).off('keydown'); - }); - var config = configService.getSync().wallet.settings; $scope.unitName = config.unitName; $scope.alternativeIsoCode = config.alternativeIsoCode; @@ -65,7 +65,6 @@ angular.module('copayApp.controllers').controller('amountController', function($ $scope.amount = (($stateParams.toAmount) * satToUnit).toFixed(unitDecimals); } - processAmount($scope.amount); $timeout(function() { @@ -187,6 +186,7 @@ angular.module('copayApp.controllers').controller('amountController', function($ var amount = $scope.showAlternativeAmount ? fromFiat(_amount).toFixed(unitDecimals) : _amount.toFixed(unitDecimals); $state.transitionTo('tabs.send.confirm', { + isWallet: $scope.isWallet, toAmount: amount * unitToSatoshi, toAddress: $scope.toAddress, toName: $scope.toName, diff --git a/src/js/controllers/confirm.js b/src/js/controllers/confirm.js index ea91048d1..6665f0a49 100644 --- a/src/js/controllers/confirm.js +++ b/src/js/controllers/confirm.js @@ -4,6 +4,7 @@ angular.module('copayApp.controllers').controller('confirmController', function( var cachedTxp = {}; var isChromeApp = platformInfo.isChromeApp; + $scope.isWallet = $stateParams.isWallet; $scope.toAddress = $stateParams.toAddress; $scope.toName = $stateParams.toName; $scope.toEmail = $stateParams.toEmail; diff --git a/src/js/controllers/tab-send.js b/src/js/controllers/tab-send.js index 58aaf6aef..f839c1a78 100644 --- a/src/js/controllers/tab-send.js +++ b/src/js/controllers/tab-send.js @@ -10,6 +10,7 @@ angular.module('copayApp.controllers').controller('tabSendController', function( var wallets = profileService.getWallets({ onlyComplete: true }); + $scope.hasWallets = lodash.isEmpty(wallets) ? false : true; lodash.each(wallets, function(v) { originalList.push({ @@ -25,6 +26,7 @@ angular.module('copayApp.controllers').controller('tabSendController', function( addressbookService.list(function(err, ab) { if (err) $log.error(err); + $scope.hasContacts = lodash.isEmpty(ab) ? false : true; var contacts = []; lodash.each(ab, function(v, k) { contacts.push({ @@ -76,6 +78,7 @@ angular.module('copayApp.controllers').controller('tabSendController', function( } $log.debug('Got toAddress:' + addr + ' | ' + item.name); return $state.transitionTo('tabs.send.amount', { + isWallet: item.isWallet, toAddress: addr, toName: item.name, toEmail: item.email diff --git a/src/js/routes.js b/src/js/routes.js index 3c4708d08..022007af4 100644 --- a/src/js/routes.js +++ b/src/js/routes.js @@ -236,8 +236,8 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr * */ - .state('tabs.send.amount', { - url: '/amount/:toAddress/:toName/:toEmail', + .state('tabs.send.amount', { + url: '/amount/:isWallet/:toAddress/:toName/:toEmail', views: { 'tab-send@tabs': { controller: 'amountController', @@ -246,7 +246,7 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr } }) .state('tabs.send.confirm', { - url: '/confirm/:toAddress/:toName/:toAmount/:toEmail/:description/:paypro', + url: '/confirm/:isWallet/:toAddress/:toName/:toAmount/:toEmail/:description/:paypro', views: { 'tab-send@tabs': { controller: 'confirmController', From 88e1d81d9a86b4a301209575e9c793675fbba9f2 Mon Sep 17 00:00:00 2001 From: Gustavo Maximiliano Cortez Date: Fri, 23 Sep 2016 17:22:03 -0300 Subject: [PATCH 4/5] Bug fixes --- public/views/tab-home.html | 8 ++++---- public/views/tab-send.html | 7 ++++--- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/public/views/tab-home.html b/public/views/tab-home.html index 483ac0555..24cb50598 100644 --- a/public/views/tab-home.html +++ b/public/views/tab-home.html @@ -35,8 +35,8 @@
-
- Wallets +
+ Wallets
-
+ Add a Contact - + {{item.name}} @@ -35,7 +36,7 @@ Transfer to Wallet
No Wallet
- + {{item.name}} From 96f961e38fac254f2167bf7d49f9469855de7d5b Mon Sep 17 00:00:00 2001 From: Gustavo Maximiliano Cortez Date: Fri, 23 Sep 2016 18:08:11 -0300 Subject: [PATCH 5/5] Bug fixes --- src/js/controllers/confirm.js | 22 ++++++++++++---------- src/js/controllers/modals/txStatus.js | 2 +- src/js/controllers/tab-receive.js | 2 +- src/js/controllers/tab-send.js | 2 +- src/js/services/incomingData.js | 9 +-------- 5 files changed, 16 insertions(+), 21 deletions(-) diff --git a/src/js/controllers/confirm.js b/src/js/controllers/confirm.js index 6665f0a49..4f0a595bd 100644 --- a/src/js/controllers/confirm.js +++ b/src/js/controllers/confirm.js @@ -5,6 +5,7 @@ angular.module('copayApp.controllers').controller('confirmController', function( var isChromeApp = platformInfo.isChromeApp; $scope.isWallet = $stateParams.isWallet; + $scope.toAmount = $stateParams.toAmount; $scope.toAddress = $stateParams.toAddress; $scope.toName = $stateParams.toName; $scope.toEmail = $stateParams.toEmail; @@ -16,15 +17,15 @@ angular.module('copayApp.controllers').controller('confirmController', function( }); var initConfirm = function() { - if ($stateParams.paypro) { - return setFromPayPro($stateParams.paypro, function(err) { + if ($scope.paypro) { + return setFromPayPro($scope.paypro, function(err) { if (err && !isChromeApp) { popupService.showAlert(gettext('Could not fetch payment')); } }); } // TODO (URL , etc) - if (!$stateParams.toAddress || !$stateParams.toAmount) { + if (!$scope.toAddress || !$scope.toAmount) { $log.error('Bad params at amount') throw ('bad params'); } @@ -34,7 +35,7 @@ angular.module('copayApp.controllers').controller('confirmController', function( var config = configService.getSync().wallet; $scope.feeLevel = config.settings ? config.settings.feeLevel : ''; - var amount = $scope.toAmount = parseInt($stateParams.toAmount); + $scope.toAmount = parseInt($scope.toAmount); $scope.amountStr = txFormatService.formatAmountStr($scope.toAmount); var networkName = (new bitcore.Address($scope.toAddress)).network.name; @@ -55,7 +56,7 @@ angular.module('copayApp.controllers').controller('confirmController', function( $log.error(err); } else { if (!status.availableBalanceSat) $log.debug('No balance available in: ' + w.name); - if (status.availableBalanceSat > amount) filteredWallets.push(w); + if (status.availableBalanceSat > $scope.toAmount) filteredWallets.push(w); } if (++index == wallets.length) { @@ -70,7 +71,7 @@ angular.module('copayApp.controllers').controller('confirmController', function( }); }); - txFormatService.formatAlternativeStr(amount, function(v) { + txFormatService.formatAlternativeStr($scope.toAmount, function(v) { $scope.alternativeAmountStr = v; }); @@ -146,12 +147,13 @@ angular.module('copayApp.controllers').controller('confirmController', function( return cb(true); } - $stateParams.toAmount = paypro.amount; - $stateParams.toAddress = paypro.toAddress; - $stateParams.description = paypro.memo; - $stateParams.paypro = null; + $scope.toAmount = paypro.amount; + $scope.toAddress = paypro.toAddress; + $scope.description = paypro.memo; + $scope.paypro = null; $scope._paypro = paypro; + return initConfirm(); }); }; diff --git a/src/js/controllers/modals/txStatus.js b/src/js/controllers/modals/txStatus.js index 4127d2172..d8383c5eb 100644 --- a/src/js/controllers/modals/txStatus.js +++ b/src/js/controllers/modals/txStatus.js @@ -3,7 +3,7 @@ angular.module('copayApp.controllers').controller('txStatusController', function($scope, $timeout, $state, $ionicHistory, $log, addressbookService) { if ($scope.cb) $timeout($scope.cb, 100); - $scope.fromSendTab = $ionicHistory.viewHistory().backView.stateName === "tabs.send.amount"; + $scope.fromSendTab = $ionicHistory.viewHistory().backView.stateName === "tabs.send.amount" || "tabs.send"; $scope.cancel = function() { $scope.txStatusModal.hide(); diff --git a/src/js/controllers/tab-receive.js b/src/js/controllers/tab-receive.js index 558f86d0d..7a1886832 100644 --- a/src/js/controllers/tab-receive.js +++ b/src/js/controllers/tab-receive.js @@ -47,7 +47,7 @@ angular.module('copayApp.controllers').controller('tabReceiveController', functi }, 1); }; - $scope.$on("$ionicView.enter", function(event, data) { + $scope.$on("$ionicView.beforeEnter", function(event, data) { if (!$scope.isCordova) $scope.checkTips(); $scope.wallets = profileService.getWallets({ onlyComplete: true diff --git a/src/js/controllers/tab-send.js b/src/js/controllers/tab-send.js index f839c1a78..ce2fb7bd6 100644 --- a/src/js/controllers/tab-send.js +++ b/src/js/controllers/tab-send.js @@ -86,7 +86,7 @@ angular.module('copayApp.controllers').controller('tabSendController', function( }); }; - $scope.$on("$ionicView.enter", function(event, data){ + $scope.$on("$ionicView.beforeEnter", function(event, data){ $scope.formData = { search: null }; updateList(); }); diff --git a/src/js/services/incomingData.js b/src/js/services/incomingData.js index 8cc754689..fc363590c 100644 --- a/src/js/services/incomingData.js +++ b/src/js/services/incomingData.js @@ -1,6 +1,6 @@ 'use strict'; -angular.module('copayApp.services').factory('incomingData', function($log, $ionicModal, $ionicHistory, $state, $window, $timeout, bitcore) { +angular.module('copayApp.services').factory('incomingData', function($log, $ionicModal, $state, $window, $timeout, bitcore) { var root = {}; @@ -26,7 +26,6 @@ angular.module('copayApp.services').factory('incomingData', function($log, $ioni // data extensions for Payment Protocol with non-backwards-compatible request if ((/^bitcoin:\?r=[\w+]/).exec(data)) { data = decodeURIComponent(data.replace('bitcoin:?r=', '')); - $ionicHistory.removeBackView(); $state.go('tabs.send'); $timeout(function() { $state.transitionTo('tabs.send.confirm', {paypro: data}); @@ -46,7 +45,6 @@ angular.module('copayApp.services').factory('incomingData', function($log, $ioni var amount = parsed.amount ? parsed.amount : ''; - $ionicHistory.removeBackView(); $state.go('tabs.send'); $timeout(function() { if (parsed.r) { @@ -63,7 +61,6 @@ angular.module('copayApp.services').factory('incomingData', function($log, $ioni // Plain URL } else if (/^https?:\/\//.test(data)) { - $ionicHistory.removeBackView(); $state.go('tabs.send'); $timeout(function() { $state.transitionTo('tabs.send.confirm', {paypro: data}); @@ -72,14 +69,12 @@ angular.module('copayApp.services').factory('incomingData', function($log, $ioni // Plain Address } else if (bitcore.Address.isValid(data, 'livenet')) { - $ionicHistory.removeBackView(); $state.go('tabs.send'); $timeout(function() { $state.transitionTo('tabs.send.amount', {toAddress: data}); }, 100); return true; } else if (bitcore.Address.isValid(data, 'testnet')) { - $ionicHistory.removeBackView(); $state.go('tabs.send'); $timeout(function() { $state.transitionTo('tabs.send.amount', {toAddress: data}); @@ -94,7 +89,6 @@ angular.module('copayApp.services').factory('incomingData', function($log, $ioni // Join } else if (data && data.match(/^copay:[0-9A-HJ-NP-Za-km-z]{70,80}$/)) { - $ionicHistory.removeBackView(); $state.go('tabs.home'); $timeout(function() { $state.transitionTo('tabs.add.join', {url: data}); @@ -103,7 +97,6 @@ angular.module('copayApp.services').factory('incomingData', function($log, $ioni // Old join } else if (data && data.match(/^[0-9A-HJ-NP-Za-km-z]{70,80}$/)) { - $ionicHistory.removeBackView(); $state.go('tabs.home'); $timeout(function() { $state.transitionTo('tabs.add.join', {url: data});