From bb27605a2eedd4522e156292e5cf98885dfed279 Mon Sep 17 00:00:00 2001 From: Javier Date: Mon, 5 Dec 2016 17:24:36 -0300 Subject: [PATCH 01/16] close modal --- src/js/controllers/onboarding/backupWarning.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/js/controllers/onboarding/backupWarning.js b/src/js/controllers/onboarding/backupWarning.js index ee57c03d5..f6e6ab68c 100644 --- a/src/js/controllers/onboarding/backupWarning.js +++ b/src/js/controllers/onboarding/backupWarning.js @@ -9,8 +9,8 @@ angular.module('copayApp.controllers').controller('backupWarningController', fun $scope.openPopup = function() { $ionicModal.fromTemplateUrl('views/includes/screenshotWarningModal.html', { scope: $scope, - backdropClickToClose: false, - hardwareBackButtonClose: false + backdropClickToClose: true, + hardwareBackButtonClose: true }).then(function(modal) { $scope.warningModal = modal; $scope.warningModal.show(); From 11f063b85d1a1516448ac14e84c77e5f07e155d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20Baz=C3=A1n?= Date: Tue, 13 Dec 2016 16:32:22 -0300 Subject: [PATCH 02/16] save last five alt currency chosen, remove infinite scroll --- src/js/controllers/preferencesAltCurrency.js | 43 +++++++++++--------- src/js/services/storageService.js | 30 +++++++++----- www/views/preferencesAltCurrency.html | 18 ++++---- 3 files changed, 54 insertions(+), 37 deletions(-) diff --git a/src/js/controllers/preferencesAltCurrency.js b/src/js/controllers/preferencesAltCurrency.js index 5f9ab9910..421e2ad16 100644 --- a/src/js/controllers/preferencesAltCurrency.js +++ b/src/js/controllers/preferencesAltCurrency.js @@ -1,38 +1,34 @@ 'use strict'; angular.module('copayApp.controllers').controller('preferencesAltCurrencyController', - function($scope, $log, $timeout, $ionicHistory, configService, rateService, lodash, profileService, walletService) { + function($scope, $log, $timeout, $ionicHistory, configService, rateService, lodash, profileService, walletService, storageService) { var next = 10; var completeAlternativeList; - var config = configService.getSync(); - $scope.currentCurrency = config.wallet.settings.alternativeIsoCode; - $scope.listComplete = false; - var unusedCurrencyList = [{ isoCode: 'LTL' }, { isoCode: 'BTC' }]; - var idx = lodash.indexBy(unusedCurrencyList, 'isoCode'); + var config = configService.getSync(); + $scope.currentCurrency = config.wallet.settings.alternativeIsoCode; rateService.whenAvailable(function() { - completeAlternativeList = lodash.reject(rateService.listAlternatives(), function(c) { - return idx[c.isoCode]; - }); - $scope.altCurrencyList = completeAlternativeList.slice(0, next); - }); + storageService.getLastCurrencyUsed(function(err, lastUsedAltCurrency) { - $scope.loadMore = function() { - $timeout(function() { - $scope.altCurrencyList = completeAlternativeList.slice(0, next); - next += 10; - $scope.listComplete = $scope.altCurrencyList.length >= completeAlternativeList.length; - $scope.$broadcast('scroll.infiniteScrollComplete'); - }, 100); - }; + $scope.lastUsedAltCurrencyList = JSON.parse(lastUsedAltCurrency) || []; + + var idx = lodash.indexBy(unusedCurrencyList, 'isoCode'); + var idx2 = lodash.indexBy($scope.lastUsedAltCurrencyList, 'isoCode'); + + completeAlternativeList = lodash.reject(rateService.listAlternatives(), function(c) { + return idx[c.isoCode] || idx2[c.isoCode]; + }); + $scope.altCurrencyList = completeAlternativeList; + }); + }); $scope.save = function(newAltCurrency) { var opts = { @@ -48,9 +44,18 @@ angular.module('copayApp.controllers').controller('preferencesAltCurrencyControl if (err) $log.warn(err); $ionicHistory.goBack(); + saveLastUsed(newAltCurrency); walletService.updateRemotePreferences(profileService.getWallets(), {}, function() { $log.debug('Remote preferences saved'); }); }); }; + + function saveLastUsed(newAltCurrency) { + $scope.lastUsedAltCurrencyList.unshift(newAltCurrency); + $scope.lastUsedAltCurrencyList = $scope.lastUsedAltCurrencyList.slice(0, 5); + $scope.lastUsedAltCurrencyList = lodash.uniq($scope.lastUsedAltCurrencyList, 'isoCode'); + storageService.setLastCurrencyUsed(JSON.stringify($scope.lastUsedAltCurrencyList), function() {}); + }; + }); diff --git a/src/js/services/storageService.js b/src/js/services/storageService.js index 7a82a1b90..f179dd1ab 100644 --- a/src/js/services/storageService.js +++ b/src/js/services/storageService.js @@ -77,25 +77,25 @@ angular.module('copayApp.services') //////////////////////////////////////////////////////////////////////////// // // UPGRADING STORAGE - // + // // 1. Write a function to upgrade the desired storage key(s). The function should have the protocol: - // + // // _upgrade_x(key, network, cb), where: - // + // // `x` is the name of the storage key - // `key` is the name of the storage key being upgraded + // `key` is the name of the storage key being upgraded // `network` is one of 'livenet', 'testnet' // // 2. Add the storage key to `_upgraders` object using the name of the key as the `_upgrader` object key // with the value being the name of the upgrade function (e.g., _upgrade_x). In order to avoid conflicts // when a storage key is involved in multiple upgraders as well as predicte the order in which upgrades - // occur the `_upgrader` object key should be prefixed with '##_' (e.g., '01_') to create a unique and + // occur the `_upgrader` object key should be prefixed with '##_' (e.g., '01_') to create a unique and // sortable name. This format is interpreted by the _upgrade() function. - // + // // Upgraders are executed in numerical order per the '##_' object key prefix. - // + // var _upgraders = { - '00_bitpayDebitCards' : _upgrade_bitpayDebitCards // 2016-11: Upgrade bitpayDebitCards-x to bitpayAccounts-x + '00_bitpayDebitCards': _upgrade_bitpayDebitCards // 2016-11: Upgrade bitpayDebitCards-x to bitpayAccounts-x }; function _upgrade_bitpayDebitCards(key, network, cb) { @@ -375,6 +375,14 @@ angular.module('copayApp.services') storage.remove('nextStep-' + service, cb); }; + root.setLastCurrencyUsed = function(lastCurrencyUsed, cb) { + storage.set('lastCurrencyUsed', lastCurrencyUsed, cb) + }; + + root.getLastCurrencyUsed = function(cb) { + storage.get('lastCurrencyUsed', cb) + }; + root.checkQuota = function() { var block = ''; // 50MB @@ -487,12 +495,14 @@ angular.module('copayApp.services') bitpayAccounts = bitpayAccounts || {}; Object.keys(bitpayAccounts).forEach(function(userId) { var data = bitpayAccounts[userId]['bitpayDebitCards-' + network]; - var newCards = lodash.reject(data.cards, {'eid': card.eid}); + var newCards = lodash.reject(data.cards, { + 'eid': card.eid + }); data.cards = newCards; root.setBitpayDebitCards(network, data, function(err) { if (err) cb(err); // If there are no more cards in storage then re-enable the next step entry. - root.getBitpayDebitCards(network, function(err, cards){ + root.getBitpayDebitCards(network, function(err, cards) { if (err) cb(err); if (cards.length == 0) { root.removeNextStep('BitpayCard', cb); diff --git a/www/views/preferencesAltCurrency.html b/www/views/preferencesAltCurrency.html index 0954fa8b5..322f58402 100644 --- a/www/views/preferencesAltCurrency.html +++ b/www/views/preferencesAltCurrency.html @@ -7,13 +7,15 @@ - {{altCurrency.name}} - - - +
+ {{lastUsedAltCurrency.name}} + +
+
+ {{altCurrency.name}} + +
From 39a2c801334f8a43a356928ac1e87c7644add7f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20Baz=C3=A1n?= Date: Tue, 13 Dec 2016 16:48:22 -0300 Subject: [PATCH 03/16] search box for currency --- src/js/controllers/preferencesAltCurrency.js | 36 ++++++++++++++------ www/views/preferencesAltCurrency.html | 7 ++++ 2 files changed, 32 insertions(+), 11 deletions(-) diff --git a/src/js/controllers/preferencesAltCurrency.js b/src/js/controllers/preferencesAltCurrency.js index 421e2ad16..5f5b83a6e 100644 --- a/src/js/controllers/preferencesAltCurrency.js +++ b/src/js/controllers/preferencesAltCurrency.js @@ -12,23 +12,36 @@ angular.module('copayApp.controllers').controller('preferencesAltCurrencyControl isoCode: 'BTC' }]; - var config = configService.getSync(); - $scope.currentCurrency = config.wallet.settings.alternativeIsoCode; + function init() { + var config = configService.getSync(); + $scope.currentCurrency = config.wallet.settings.alternativeIsoCode; - rateService.whenAvailable(function() { - storageService.getLastCurrencyUsed(function(err, lastUsedAltCurrency) { + rateService.whenAvailable(function() { + storageService.getLastCurrencyUsed(function(err, lastUsedAltCurrency) { - $scope.lastUsedAltCurrencyList = JSON.parse(lastUsedAltCurrency) || []; + $scope.lastUsedAltCurrencyList = JSON.parse(lastUsedAltCurrency) || []; - var idx = lodash.indexBy(unusedCurrencyList, 'isoCode'); - var idx2 = lodash.indexBy($scope.lastUsedAltCurrencyList, 'isoCode'); + var idx = lodash.indexBy(unusedCurrencyList, 'isoCode'); + var idx2 = lodash.indexBy($scope.lastUsedAltCurrencyList, 'isoCode'); - completeAlternativeList = lodash.reject(rateService.listAlternatives(), function(c) { - return idx[c.isoCode] || idx2[c.isoCode]; + $scope.completeAlternativeList = lodash.reject(rateService.listAlternatives(), function(c) { + return idx[c.isoCode] || idx2[c.isoCode]; + }); + $scope.altCurrencyList = $scope.completeAlternativeList; }); - $scope.altCurrencyList = completeAlternativeList; }); - }); + } + + $scope.findCurrency = function(search) { + if (!search) init(); + $scope.altCurrencyList = lodash.filter($scope.completeAlternativeList, function(item) { + var val = item.name; + return lodash.includes(val.toLowerCase(), search.toLowerCase()); + }); + $timeout(function() { + $scope.$apply(); + }); + }; $scope.save = function(newAltCurrency) { var opts = { @@ -58,4 +71,5 @@ angular.module('copayApp.controllers').controller('preferencesAltCurrencyControl storageService.setLastCurrencyUsed(JSON.stringify($scope.lastUsedAltCurrencyList), function() {}); }; + init(); }); diff --git a/www/views/preferencesAltCurrency.html b/www/views/preferencesAltCurrency.html index 322f58402..dc51757a2 100644 --- a/www/views/preferencesAltCurrency.html +++ b/www/views/preferencesAltCurrency.html @@ -7,6 +7,13 @@ +
+ +
{{lastUsedAltCurrency.name}} From 6aedf9a75fe8a27e129116219d9b339b75dfb8c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20Baz=C3=A1n?= Date: Tue, 13 Dec 2016 17:04:46 -0300 Subject: [PATCH 04/16] add margin bottom --- www/views/preferencesAltCurrency.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/views/preferencesAltCurrency.html b/www/views/preferencesAltCurrency.html index dc51757a2..1a59c60f3 100644 --- a/www/views/preferencesAltCurrency.html +++ b/www/views/preferencesAltCurrency.html @@ -7,7 +7,7 @@ -
+
-
Hardware wallet
From 3102e6ffbbb3389d88cb521b6f149a67d3b8e26f Mon Sep 17 00:00:00 2001 From: Javier Date: Wed, 14 Dec 2016 11:15:22 -0300 Subject: [PATCH 08/16] disable only for copay distribution --- src/js/controllers/create.js | 33 ++++++++++++++++++--------------- src/js/controllers/import.js | 3 ++- src/js/controllers/join.js | 31 +++++++++++++++++-------------- www/views/import.html | 4 ++-- 4 files changed, 39 insertions(+), 32 deletions(-) diff --git a/src/js/controllers/create.js b/src/js/controllers/create.js index cb86415a2..3d948d295 100644 --- a/src/js/controllers/create.js +++ b/src/js/controllers/create.js @@ -1,7 +1,7 @@ 'use strict'; angular.module('copayApp.controllers').controller('createController', - function($scope, $rootScope, $timeout, $log, lodash, $state, $ionicScrollDelegate, $ionicHistory, profileService, configService, gettextCatalog, ledger, trezor, platformInfo, derivationPathHelper, ongoingProcess, walletService, storageService, popupService) { + function($scope, $rootScope, $timeout, $log, lodash, $state, $ionicScrollDelegate, $ionicHistory, profileService, configService, gettextCatalog, ledger, trezor, platformInfo, derivationPathHelper, ongoingProcess, walletService, storageService, popupService, $window) { var isChromeApp = platformInfo.isChromeApp; var isCordova = platformInfo.isCordova; @@ -33,7 +33,6 @@ angular.module('copayApp.controllers').controller('createController', $scope.formData.derivationPath = derivationPathHelper.default; $scope.setTotalCopayers(tc); updateRCSelect(tc); - updateSeedSourceSelect(tc); }; $scope.showAdvChange = function() { @@ -77,21 +76,25 @@ angular.module('copayApp.controllers').controller('createController', /* - Disable Hardware Wallets + Disable Hardware Wallets for BitPay distribution - if (n > 1 && isChromeApp) { - seedOptions.push({ - id: 'ledger', - label: 'Ledger Hardware Wallet', - }); - } - if (isChromeApp || isDevel) { - seedOptions.push({ - id: 'trezor', - label: 'Trezor Hardware Wallet', - }); - } */ + + if ($window.appConfig.name == 'copay') { + if (n > 1 && isChromeApp) { + seedOptions.push({ + id: 'ledger', + label: 'Ledger Hardware Wallet', + }); + } + if (isChromeApp || isDevel) { + seedOptions.push({ + id: 'trezor', + label: 'Trezor Hardware Wallet', + }); + } + } + $scope.seedOptions = seedOptions; }; diff --git a/src/js/controllers/import.js b/src/js/controllers/import.js index af9dd6e31..3d3b1fbce 100644 --- a/src/js/controllers/import.js +++ b/src/js/controllers/import.js @@ -1,7 +1,7 @@ 'use strict'; angular.module('copayApp.controllers').controller('importController', - function($scope, $timeout, $log, $state, $stateParams, $ionicHistory, $ionicScrollDelegate, profileService, configService, sjcl, ledger, trezor, derivationPathHelper, platformInfo, bwcService, ongoingProcess, walletService, popupService, gettextCatalog) { + function($scope, $timeout, $log, $state, $stateParams, $ionicHistory, $ionicScrollDelegate, profileService, configService, sjcl, ledger, trezor, derivationPathHelper, platformInfo, bwcService, ongoingProcess, walletService, popupService, gettextCatalog, $window) { var isChromeApp = platformInfo.isChromeApp; var isDevel = platformInfo.isDevel; @@ -17,6 +17,7 @@ angular.module('copayApp.controllers').controller('importController', $scope.formData.derivationPath = derivationPathHelper.default; $scope.formData.account = 1; $scope.importErr = false; + $scope.showHardwareWallet = $window.appConfig.name == 'copay'; if ($stateParams.code) $scope.processWalletInfo($stateParams.code); diff --git a/src/js/controllers/join.js b/src/js/controllers/join.js index 35d0bd2d8..3b0362d60 100644 --- a/src/js/controllers/join.js +++ b/src/js/controllers/join.js @@ -1,7 +1,7 @@ 'use strict'; angular.module('copayApp.controllers').controller('joinController', - function($scope, $rootScope, $timeout, $state, $ionicHistory, $ionicScrollDelegate, profileService, configService, storageService, applicationService, gettextCatalog, lodash, ledger, trezor, platformInfo, derivationPathHelper, ongoingProcess, walletService, $log, $stateParams, popupService) { + function($scope, $rootScope, $timeout, $state, $ionicHistory, $ionicScrollDelegate, profileService, configService, storageService, applicationService, gettextCatalog, lodash, ledger, trezor, platformInfo, derivationPathHelper, ongoingProcess, walletService, $log, $stateParams, popupService, $window) { var isChromeApp = platformInfo.isChromeApp; var isDevel = platformInfo.isDevel; @@ -61,20 +61,23 @@ angular.module('copayApp.controllers').controller('joinController', Disable Hardware Wallets - if (isChromeApp) { - self.seedOptions.push({ - id: 'ledger', - label: 'Ledger Hardware Wallet', - }); - } - - if (isChromeApp || isDevel) { - self.seedOptions.push({ - id: 'trezor', - label: 'Trezor Hardware Wallet', - }); - } */ + + if ($window.appConfig.name == 'copay') { + if (isChromeApp) { + self.seedOptions.push({ + id: 'ledger', + label: 'Ledger Hardware Wallet', + }); + } + + if (isChromeApp || isDevel) { + self.seedOptions.push({ + id: 'trezor', + label: 'Trezor Hardware Wallet', + }); + } + } }; this.setSeedSource = function() { diff --git a/www/views/import.html b/www/views/import.html index 9de688897..e3a7af0c7 100644 --- a/www/views/import.html +++ b/www/views/import.html @@ -15,8 +15,8 @@ {'border-bottom-style': 'solid'}"> File/Text
-
+
Hardware wallet
From 6704b31ab2d661095962a2528d409707885c05b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20Baz=C3=A1n?= Date: Wed, 14 Dec 2016 11:44:55 -0300 Subject: [PATCH 09/16] adding infinite scroll again --- src/js/controllers/preferencesAltCurrency.js | 33 +++++++++++++------- www/views/preferencesAltCurrency.html | 5 +++ 2 files changed, 27 insertions(+), 11 deletions(-) diff --git a/src/js/controllers/preferencesAltCurrency.js b/src/js/controllers/preferencesAltCurrency.js index 9fba5d220..20e1e16dd 100644 --- a/src/js/controllers/preferencesAltCurrency.js +++ b/src/js/controllers/preferencesAltCurrency.js @@ -3,6 +3,9 @@ angular.module('copayApp.controllers').controller('preferencesAltCurrencyController', function($scope, $log, $timeout, $ionicHistory, configService, rateService, lodash, profileService, walletService, storageService) { + var next = 10; + var completeAlternativeList; + function init() { var unusedCurrencyList = [{ isoCode: 'LTL' @@ -11,22 +14,38 @@ angular.module('copayApp.controllers').controller('preferencesAltCurrencyControl }]; rateService.whenAvailable(function() { + $scope.listComplete = false; + var idx = lodash.indexBy(unusedCurrencyList, 'isoCode'); var idx2 = lodash.indexBy($scope.lastUsedAltCurrencyList, 'isoCode'); - $scope.completeAlternativeList = lodash.reject(rateService.listAlternatives(), function(c) { + completeAlternativeList = lodash.reject(rateService.listAlternatives(), function(c) { return idx[c.isoCode] || idx2[c.isoCode]; }); - $scope.altCurrencyList = $scope.completeAlternativeList; + + completeAlternativeList = completeAlternativeList.sort(function(a, b) { + return a.name.toLowerCase() > b.name.toLowerCase() ? 1 : -1; + }); + + $scope.altCurrencyList = completeAlternativeList.slice(0, 10); $timeout(function() { $scope.$apply(); }); }); } + $scope.loadMore = function() { + $timeout(function() { + $scope.altCurrencyList = completeAlternativeList.slice(0, next); + next += 10; + $scope.listComplete = $scope.altCurrencyList.length >= completeAlternativeList.length; + $scope.$broadcast('scroll.infiniteScrollComplete'); + }, 100); + }; + $scope.findCurrency = function(search) { if (!search) init(); - $scope.altCurrencyList = lodash.filter($scope.completeAlternativeList, function(item) { + $scope.altCurrencyList = lodash.filter(completeAlternativeList, function(item) { var val = item.name; return lodash.includes(val.toLowerCase(), search.toLowerCase()); }); @@ -68,14 +87,6 @@ angular.module('copayApp.controllers').controller('preferencesAltCurrencyControl $scope.currentCurrency = config.wallet.settings.alternativeIsoCode; storageService.getLastCurrencyUsed(function(err, lastUsedAltCurrency) { $scope.lastUsedAltCurrencyList = lastUsedAltCurrency ? JSON.parse(lastUsedAltCurrency) : []; - $timeout(function() { - $scope.$apply(); - }); - }); - }); - - $scope.$on("$ionicView.enter", function(event, data) { - $timeout(function() { init(); }); }); diff --git a/www/views/preferencesAltCurrency.html b/www/views/preferencesAltCurrency.html index 1a59c60f3..dc9be4286 100644 --- a/www/views/preferencesAltCurrency.html +++ b/www/views/preferencesAltCurrency.html @@ -24,5 +24,10 @@ ng-click="save(altCurrency)">{{altCurrency.name}}
+ +
From 880e3ebe141f8fd0452141487ba43b5ab512aff4 Mon Sep 17 00:00:00 2001 From: Javier Date: Wed, 14 Dec 2016 13:24:02 -0300 Subject: [PATCH 10/16] use contact name in proposal card --- src/js/controllers/proposals.js | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/src/js/controllers/proposals.js b/src/js/controllers/proposals.js index 2fa6193a0..03d8492c9 100644 --- a/src/js/controllers/proposals.js +++ b/src/js/controllers/proposals.js @@ -1,22 +1,26 @@ - 'use strict'; angular.module('copayApp.controllers').controller('proposalsController', - function($timeout, $scope, profileService, $log, txpModalService) { + function($timeout, $scope, profileService, $log, txpModalService, addressbookService) { $scope.fetchingProposals = true; - $scope.$on("$ionicView.enter", function(event, data){ - profileService.getTxps(50, function(err, txps) { - $scope.fetchingProposals = false; - if (err) { - $log.error(err); - return; - } - $scope.txps = txps; - $timeout(function() { - $scope.$apply(); - }, 1); + $scope.$on("$ionicView.enter", function(event, data) { + addressbookService.list(function(err, ab) { + if (err) $log.error(err); + $scope.addressbook = ab || {}; + + profileService.getTxps(50, function(err, txps) { + $scope.fetchingProposals = false; + if (err) { + $log.error(err); + return; + } + $scope.txps = txps; + $timeout(function() { + $scope.$apply(); + }); + }); }); }); From e1fbc1202f4dd646614c1f8263ce0820733c23a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20Baz=C3=A1n?= Date: Wed, 14 Dec 2016 14:57:14 -0300 Subject: [PATCH 11/16] fix sidebar wallets selection --- src/js/controllers/tab-receive.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/js/controllers/tab-receive.js b/src/js/controllers/tab-receive.js index 14a61732a..3aeb9d577 100644 --- a/src/js/controllers/tab-receive.js +++ b/src/js/controllers/tab-receive.js @@ -86,7 +86,7 @@ angular.module('copayApp.controllers').controller('tabReceiveController', functi $scope.setWallet = function(index) { $scope.wallet = $scope.wallets[index]; $scope.walletIndex = index; - if ($scope.walletAddrs[$scope.walletIndex].addr) $scope.addr = $scope.walletAddrs[$scope.walletIndex].addr; + if ($scope.walletAddrs[$scope.wallet.id].addr) $scope.addr = $scope.walletAddrs[$scope.walletIndex].addr; else $scope.setAddress(false); } From 92a21046b289d1845dd0529562ee651553c8e217 Mon Sep 17 00:00:00 2001 From: Gustavo Maximiliano Cortez Date: Wed, 14 Dec 2016 15:26:56 -0300 Subject: [PATCH 12/16] Fix creating transaction with no priv key --- src/js/controllers/confirm.js | 28 +++++++++++++++++----------- src/js/services/walletService.js | 18 ++++++------------ www/views/confirm.html | 5 +++-- 3 files changed, 26 insertions(+), 25 deletions(-) diff --git a/src/js/controllers/confirm.js b/src/js/controllers/confirm.js index ee0f148ae..36573dbfb 100644 --- a/src/js/controllers/confirm.js +++ b/src/js/controllers/confirm.js @@ -483,20 +483,12 @@ angular.module('copayApp.controllers').controller('confirmController', function( } }); return; - } - - if (!wallet.canSign() && !wallet.isPrivKeyExternal()) { - $log.info('No signing proposal: No private key'); - - return walletService.onlyPublish(wallet, txp, function(err, txp) { - if (err) return setSendError(err); - }); - } + } ongoingProcess.set('creatingTx', true, onSendStatusChange); createTx(wallet, false, function(err, txp) { ongoingProcess.set('creatingTx', false, onSendStatusChange); - if (err) return; + if (err) return; var config = configService.getSync(); var spendingPassEnabled = walletService.isEncrypted(wallet); @@ -539,7 +531,12 @@ angular.module('copayApp.controllers').controller('confirmController', function( function statusChangeHandler(processName, showName, isOn) { $log.debug('statusChangeHandler: ', processName, showName, isOn); - if ((processName === 'broadcastingTx' || ((processName === 'signingTx') && $scope.wallet.m > 1)) && !isOn) { + if ( + ( + processName === 'broadcastingTx' || + ((processName === 'signingTx') && $scope.wallet.m > 1) || + (processName == 'sendingTx' && !$scope.wallet.canSign() && !$scope.wallet.isPrivKeyExternal()) + ) && !isOn) { $scope.sendStatus = 'success'; $scope.$digest(); } else if (showName) { @@ -760,6 +757,15 @@ angular.module('copayApp.controllers').controller('confirmController', function( }; function publishAndSign(wallet, txp, onSendStatusChange) { + + if (!wallet.canSign() && !wallet.isPrivKeyExternal()) { + $log.info('No signing proposal: No private key'); + + return walletService.onlyPublish(wallet, txp, function(err) { + if (err) setSendError(err); + }, onSendStatusChange); + } + walletService.publishAndSign(wallet, txp, function(err, txp) { if (err) return setSendError(err); diff --git a/src/js/services/walletService.js b/src/js/services/walletService.js index da59c5ffd..c84c438df 100644 --- a/src/js/services/walletService.js +++ b/src/js/services/walletService.js @@ -889,20 +889,14 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim }; - root.onlyPublish = function(wallet, txp, cb) { - ongoingProcess.set('sendingTx', true); + root.onlyPublish = function(wallet, txp, cb, customStatusHandler) { + ongoingProcess.set('sendingTx', true, customStatusHandler); root.publishTx(wallet, txp, function(err, publishedTxp) { root.invalidateCache(wallet); - - ongoingProcess.set('sendingTx', false); - if (err) return cb(err); - - var type = root.getViewStatus(wallet, createdTxp); - root.openStatusModal(type, createdTxp, function() { - $rootScope.$emit('Local/TxAction', wallet.id); - return; - }); - return cb(null, publishedTxp); + ongoingProcess.set('sendingTx', false, customStatusHandler); + if (err) return cb(bwcError.msg(err)); + $rootScope.$emit('Local/TxAction', wallet.id); + return cb(); }); }; diff --git a/www/views/confirm.html b/www/views/confirm.html index 9af5b7664..bc686ad9c 100644 --- a/www/views/confirm.html +++ b/www/views/confirm.html @@ -137,8 +137,9 @@ slide-success-show="sendStatus === 'success'" slide-success-on-confirm="onSuccessConfirm()" slide-success-hide-on-confirm="true"> - Payment Sent - Proposal Created + Payment Sent + Proposal Created + Transaction created
A transfer has been initiated from your bank account. Your bitcoins should arrive to your wallet in 2-4 business day A transfer has been initiated to your bank account. Should arrive in 4-6 business days From db987e48171ef6a7b3c8fc4952c7e6630993bc54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20Baz=C3=A1n?= Date: Wed, 14 Dec 2016 15:37:15 -0300 Subject: [PATCH 13/16] fix scroll resize in send view and adding timeout to ionicScrollDelegate.resize --- src/js/controllers/addresses.js | 4 ++-- src/js/controllers/advancedSettings.js | 18 ++++++++++-------- src/js/controllers/create.js | 2 +- src/js/controllers/export.js | 2 +- src/js/controllers/import.js | 2 +- src/js/controllers/join.js | 2 +- src/js/controllers/tab-home.js | 6 +++--- src/js/controllers/tab-send.js | 8 ++++---- 8 files changed, 23 insertions(+), 21 deletions(-) diff --git a/src/js/controllers/addresses.js b/src/js/controllers/addresses.js index 9b31e431f..90cf0bb5e 100644 --- a/src/js/controllers/addresses.js +++ b/src/js/controllers/addresses.js @@ -104,14 +104,14 @@ angular.module('copayApp.controllers').controller('addressesController', functio $timeout(function() { $scope.showInfo = !$scope.showInfo; $ionicScrollDelegate.resize(); - }); + }, 10); }; $scope.readMore = function() { $timeout(function() { $scope.showMore = !$scope.showMore; $ionicScrollDelegate.resize(); - }); + }, 10); }; $scope.showMenu = function(allAddresses, $event) { diff --git a/src/js/controllers/advancedSettings.js b/src/js/controllers/advancedSettings.js index 22256de57..4abb4c261 100644 --- a/src/js/controllers/advancedSettings.js +++ b/src/js/controllers/advancedSettings.js @@ -30,22 +30,24 @@ angular.module('copayApp.controllers').controller('advancedSettingsController', }; $scope.global = $rootScope; - if(!$scope.global.developmentUtilitiesEnabled){ + if (!$scope.global.developmentUtilitiesEnabled) { $scope.global.developmentUtilitiesEnabled = { value: false }; } - $scope.toggledDevelopmentUtils = function (){ - if($scope.global.developmentUtilitiesEnabled.value){ + $scope.toggledDevelopmentUtils = function() { + if ($scope.global.developmentUtilitiesEnabled.value) { $log.debug('User enabled development utilities.'); - $ionicScrollDelegate.resize(); + $timeout(function() { + $ionicScrollDelegate.resize(); + }, 10); } else { $log.debug('User disabled development utilities.'); } } - $scope.activateFeedbackCard = function () { + $scope.activateFeedbackCard = function() { $scope.feedbackCardActivating = true; storageService.getFeedbackInfo(function(error, info) { var feedbackInfo = JSON.parse(info); @@ -56,10 +58,10 @@ angular.module('copayApp.controllers').controller('advancedSettingsController', storageService.setFeedbackInfo(JSON.stringify(feedbackInfo), function() { $log.debug('Activated feedback card with: ' + JSON.stringify(feedbackInfo)); $ionicHistory.clearCache(); - $timeout(function(){ + $timeout(function() { $scope.feedbackCardActivating = false; $scope.feedbackCardActivated = true; - $timeout(function(){ + $timeout(function() { $scope.feedbackCardActivated = false; }, 10000); }, 500); @@ -67,7 +69,7 @@ angular.module('copayApp.controllers').controller('advancedSettingsController', }); } - $scope.resetActivateFeedbackCard = function(){ + $scope.resetActivateFeedbackCard = function() { $scope.feedbackCardActivated = false; } diff --git a/src/js/controllers/create.js b/src/js/controllers/create.js index 3d948d295..ed567bf0d 100644 --- a/src/js/controllers/create.js +++ b/src/js/controllers/create.js @@ -43,7 +43,7 @@ angular.module('copayApp.controllers').controller('createController', $scope.resizeView = function() { $timeout(function() { $ionicScrollDelegate.resize(); - }); + }, 10); checkPasswordFields(); }; diff --git a/src/js/controllers/export.js b/src/js/controllers/export.js index 358a211da..bec190995 100644 --- a/src/js/controllers/export.js +++ b/src/js/controllers/export.js @@ -12,7 +12,7 @@ angular.module('copayApp.controllers').controller('exportController', $scope.resizeView = function() { $timeout(function() { $ionicScrollDelegate.resize(); - }); + }, 10); }; function getPassword(cb) { diff --git a/src/js/controllers/import.js b/src/js/controllers/import.js index 3d3b1fbce..959509775 100644 --- a/src/js/controllers/import.js +++ b/src/js/controllers/import.js @@ -360,7 +360,7 @@ angular.module('copayApp.controllers').controller('importController', $scope.resizeView = function() { $timeout(function() { $ionicScrollDelegate.resize(); - }); + }, 10); }; }); diff --git a/src/js/controllers/join.js b/src/js/controllers/join.js index 3b0362d60..8dbf6cffb 100644 --- a/src/js/controllers/join.js +++ b/src/js/controllers/join.js @@ -20,7 +20,7 @@ angular.module('copayApp.controllers').controller('joinController', $scope.resizeView = function() { $timeout(function() { $ionicScrollDelegate.resize(); - }); + }, 10); checkPasswordFields(); }; diff --git a/src/js/controllers/tab-home.js b/src/js/controllers/tab-home.js index d520ef88e..a2ca1950d 100644 --- a/src/js/controllers/tab-home.js +++ b/src/js/controllers/tab-home.js @@ -187,7 +187,7 @@ angular.module('copayApp.controllers').controller('tabHomeController', $timeout(function() { $ionicScrollDelegate.resize(); $scope.$apply(); - }, 100); + }, 10); }) }; @@ -240,7 +240,7 @@ angular.module('copayApp.controllers').controller('tabHomeController', $timeout(function() { $ionicScrollDelegate.resize(); $scope.$apply(); - }, 100); + }, 10); }); }; @@ -269,7 +269,7 @@ angular.module('copayApp.controllers').controller('tabHomeController', $timeout(function() { $ionicScrollDelegate.resize(); $scope.$apply(); - }, 100); + }, 10); }; var bitpayCardCache = function() { diff --git a/src/js/controllers/tab-send.js b/src/js/controllers/tab-send.js index b905b16a6..c4deabc97 100644 --- a/src/js/controllers/tab-send.js +++ b/src/js/controllers/tab-send.js @@ -55,7 +55,7 @@ angular.module('copayApp.controllers').controller('tabSendController', function( $timeout(function() { $ionicScrollDelegate.resize(); $scope.$apply(); - }); + }, 10); }); }; @@ -145,15 +145,15 @@ angular.module('copayApp.controllers').controller('tabSendController', function( if (index == wallets.length) { $scope.checkingBalance = false; + if ($scope.hasFunds != true) { + $ionicScrollDelegate.freezeScroll(true); + } $timeout(function() { $scope.$apply(); }); } }); }); - if ($scope.hasFunds != true) { - $ionicScrollDelegate.freezeScroll(true); - } }; $scope.$on("$ionicView.beforeEnter", function(event, data) { From faab393dc06cf846781363999be2106d82a645e0 Mon Sep 17 00:00:00 2001 From: Javier Date: Wed, 14 Dec 2016 15:18:52 -0300 Subject: [PATCH 14/16] fix time format --- src/js/controllers/proposals.js | 6 ++++++ src/js/controllers/tab-home.js | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/src/js/controllers/proposals.js b/src/js/controllers/proposals.js index 03d8492c9..1e0e65030 100644 --- a/src/js/controllers/proposals.js +++ b/src/js/controllers/proposals.js @@ -25,4 +25,10 @@ angular.module('copayApp.controllers').controller('proposalsController', }); $scope.openTxpModal = txpModalService.open; + + $scope.createdWithinPastDay = function(time) { + var now = new Date(); + var date = new Date(time * 1000); + return (now.getTime() - date.getTime()) < (1000 * 60 * 60 * 24); + }; }); diff --git a/src/js/controllers/tab-home.js b/src/js/controllers/tab-home.js index d520ef88e..3550703ca 100644 --- a/src/js/controllers/tab-home.js +++ b/src/js/controllers/tab-home.js @@ -126,6 +126,12 @@ angular.module('copayApp.controllers').controller('tabHomeController', }); }); + $scope.createdWithinPastDay = function(time) { + var now = new Date(); + var date = new Date(time * 1000); + return (now.getTime() - date.getTime()) < (1000 * 60 * 60 * 24); + }; + $scope.openExternalLink = function() { var url = 'https://github.com/bitpay/copay/releases/latest'; var optIn = true; From 5e291cbb414ca25cd1f928c68ce3d8ffbd6a093f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20Baz=C3=A1n?= Date: Wed, 14 Dec 2016 16:31:19 -0300 Subject: [PATCH 15/16] fix translations and wording --- www/views/confirm.html | 14 +++++++------- www/views/modals/txp-details.html | 6 +++--- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/www/views/confirm.html b/www/views/confirm.html index bc686ad9c..a3cef657d 100644 --- a/www/views/confirm.html +++ b/www/views/confirm.html @@ -58,8 +58,8 @@
From - To - From + To + From
@@ -123,7 +123,7 @@ ng-if="!isCordova && wallets[0] && !insufficientFunds && !noMatchingWallet" click-send-status="sendStatus" has-wallet-chosen="wallet"> - Click to pay + {{'Accept' | translate}} - Slide to pay + {{'Accept' | translate}} - Payment Sent - Proposal Created - Transaction created + Payment Sent + Proposal Created + Transaction created
A transfer has been initiated from your bank account. Your bitcoins should arrive to your wallet in 2-4 business day A transfer has been initiated to your bank account. Should arrive in 4-6 business days diff --git a/www/views/modals/txp-details.html b/www/views/modals/txp-details.html index ba62411f0..1496acc64 100644 --- a/www/views/modals/txp-details.html +++ b/www/views/modals/txp-details.html @@ -166,19 +166,19 @@ ng-if="tx.pendingForUs && canSign && !paymentExpired && hasClick" click-send-status="sendStatus" has-wallet-chosen="true"> - Click to accept + {{'Accept'| translate}} - Slide to accept + {{'Accept'| translate}} - Payment Sent + {{'Payment Sent' | translate}} From 6add7424de277bd43e9fabb2b362987e1cbc9f83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20Baz=C3=A1n?= Date: Thu, 15 Dec 2016 15:49:02 -0300 Subject: [PATCH 16/16] fix repeated currencies --- src/js/controllers/preferencesAltCurrency.js | 8 +++----- src/js/services/rateService.js | 10 ++++++++-- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/js/controllers/preferencesAltCurrency.js b/src/js/controllers/preferencesAltCurrency.js index 20e1e16dd..6e45f40bc 100644 --- a/src/js/controllers/preferencesAltCurrency.js +++ b/src/js/controllers/preferencesAltCurrency.js @@ -19,15 +19,12 @@ angular.module('copayApp.controllers').controller('preferencesAltCurrencyControl var idx = lodash.indexBy(unusedCurrencyList, 'isoCode'); var idx2 = lodash.indexBy($scope.lastUsedAltCurrencyList, 'isoCode'); - completeAlternativeList = lodash.reject(rateService.listAlternatives(), function(c) { + completeAlternativeList = lodash.reject(rateService.listAlternatives(true), function(c) { return idx[c.isoCode] || idx2[c.isoCode]; }); - completeAlternativeList = completeAlternativeList.sort(function(a, b) { - return a.name.toLowerCase() > b.name.toLowerCase() ? 1 : -1; - }); - $scope.altCurrencyList = completeAlternativeList.slice(0, 10); + $timeout(function() { $scope.$apply(); }); @@ -85,6 +82,7 @@ angular.module('copayApp.controllers').controller('preferencesAltCurrencyControl $scope.$on("$ionicView.beforeEnter", function(event, data) { var config = configService.getSync(); $scope.currentCurrency = config.wallet.settings.alternativeIsoCode; + storageService.getLastCurrencyUsed(function(err, lastUsedAltCurrency) { $scope.lastUsedAltCurrencyList = lastUsedAltCurrency ? JSON.parse(lastUsedAltCurrency) : []; init(); diff --git a/src/js/services/rateService.js b/src/js/services/rateService.js index 394c556b4..9cbfe2821 100644 --- a/src/js/services/rateService.js +++ b/src/js/services/rateService.js @@ -111,18 +111,24 @@ RateService.prototype.fromFiat = function(amount, code) { return amount / this.getRate(code) * this.BTC_TO_SAT; }; -RateService.prototype.listAlternatives = function() { +RateService.prototype.listAlternatives = function(sort) { var self = this; if (!this.isAvailable()) { return []; } - return self.lodash.map(this.getAlternatives(), function(item) { + var alternatives = self.lodash.map(this.getAlternatives(), function(item) { return { name: item.name, isoCode: item.isoCode } }); + if (sort) { + alternatives.sort(function(a, b) { + return a.name.toLowerCase() > b.name.toLowerCase() ? 1 : -1; + }); + } + return self.lodash.uniq(alternatives, 'isoCode'); }; angular.module('copayApp.services').factory('rateService', function($http, lodash) {