From b720821d4e4f7e6837e7c7b3bae1a793c8642eeb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20Edgardo=20Baz=C3=A1n?= Date: Wed, 13 Apr 2016 17:46:25 +0200 Subject: [PATCH] Fix fee levels when there is no wallet and hide Glidera if wallet is not complete (#4068) * fix cordova is not define * Remove focused client from fee level service * remove wallet should be complete in route.js for global preferences routes * get network of the focused client in getCurrentFeeValue function * refactor * do not show testnet fee levels in preference global and refactors * bump new version bwc v2.2.1 --- package.json | 2 +- public/views/includes/sidebar.html | 2 +- public/views/preferencesFee.html | 11 ++++----- public/views/preferencesGlobal.html | 2 +- src/js/controllers/index.js | 8 +++--- src/js/controllers/preferencesGlobal.js | 4 +-- src/js/routes.js | 9 +------ src/js/services/feeService.js | 33 +++++++++++++++---------- 8 files changed, 34 insertions(+), 37 deletions(-) diff --git a/package.json b/package.json index 59037cb0a..3c80d256a 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "url": "https://github.com/bitpay/copay/issues" }, "dependencies": { - "bitcore-wallet-client": "2.1.1", + "bitcore-wallet-client": "2.2.1", "express": "^4.11.2", "fs": "0.0.2", "grunt": "^0.4.5", diff --git a/public/views/includes/sidebar.html b/public/views/includes/sidebar.html index 4b37bb4d7..3f2d93506 100644 --- a/public/views/includes/sidebar.html +++ b/public/views/includes/sidebar.html @@ -28,7 +28,7 @@
Create, join or import
-
  • +
  • diff --git a/public/views/preferencesFee.html b/public/views/preferencesFee.html index c411813cd..6d775615c 100644 --- a/public/views/preferencesFee.html +++ b/public/views/preferencesFee.html @@ -1,5 +1,5 @@ -
    @@ -21,8 +21,8 @@ -
      -
    • +
    • {{prefFee.feeOpts[fee.level]|translate}} @@ -30,8 +30,7 @@
    -
    +
    Average confirmation time: {{fee.nbBlocks * 10}} minutes.
    diff --git a/public/views/preferencesGlobal.html b/public/views/preferencesGlobal.html index fd296396c..2b80961e5 100644 --- a/public/views/preferencesGlobal.html +++ b/public/views/preferencesGlobal.html @@ -78,7 +78,7 @@
    About Copay
  • -
    +
    Push notifications for Copay are currently disabled. Enable them in the Settings app.
    • Open Settings app
    • diff --git a/src/js/controllers/index.js b/src/js/controllers/index.js index 0718a29bf..9a2061648 100644 --- a/src/js/controllers/index.js +++ b/src/js/controllers/index.js @@ -295,8 +295,10 @@ angular.module('copayApp.controllers').controller('indexController', function($r self.updateAll = function(opts, initStatusHash, tries) { tries = tries || 0; opts = opts || {}; + var fc = profileService.focusedClient; + if (!fc) return; - var walletId = profileService.focusedClient.credentials.walletId + var walletId = fc.credentials.walletId if (opts.untilItChanges && lodash.isUndefined(initStatusHash)) { initStatusHash = _walletStatusHash(); @@ -321,10 +323,6 @@ angular.module('copayApp.controllers').controller('indexController', function($r } }; - var fc = profileService.focusedClient; - if (!fc) return; - - // If not untilItChanges...trigger history update now if (opts.triggerTxUpdate && !opts.untilItChanges) { $timeout(function() { diff --git a/src/js/controllers/preferencesGlobal.js b/src/js/controllers/preferencesGlobal.js index 8cedfe62b..ba56f5223 100644 --- a/src/js/controllers/preferencesGlobal.js +++ b/src/js/controllers/preferencesGlobal.js @@ -15,8 +15,8 @@ angular.module('copayApp.controllers').controller('preferencesGlobalController', this.currentFeeLevel = feeService.getCurrentFeeLevel(); this.usePushNotifications = isCordova && !isMobile.Windows(); $scope.PNEnabledByUser = true; - $scope.isIOS = isMobile.iOS(); - if (!typeof cordova.plugins.diagnostic != undefined && $scope.isIOS) { + $scope.isIOSApp = isMobile.iOS() && isCordova; + if ($scope.isIOSApp) { cordova.plugins.diagnostic.isRemoteNotificationsEnabled(function(isEnabled) { $scope.PNEnabledByUser = isEnabled; }); diff --git a/src/js/routes.js b/src/js/routes.js index 222f45f26..134bca2e7 100644 --- a/src/js/routes.js +++ b/src/js/routes.js @@ -78,7 +78,6 @@ angular $stateProvider .state('translators', { url: '/translators', - walletShouldBeComplete: true, needProfile: true, views: { 'main': { @@ -194,7 +193,6 @@ angular }) .state('preferencesLanguage', { url: '/preferencesLanguage', - walletShouldBeComplete: true, needProfile: true, views: { 'main': { @@ -205,7 +203,6 @@ angular .state('preferencesUnit', { url: '/preferencesUnit', templateUrl: 'views/preferencesUnit.html', - walletShouldBeComplete: true, needProfile: true, views: { 'main': { @@ -216,7 +213,6 @@ angular .state('preferencesFee', { url: '/preferencesFee', templateUrl: 'views/preferencesFee.html', - walletShouldBeComplete: true, needProfile: true, views: { 'main': { @@ -298,7 +294,6 @@ angular .state('preferencesAltCurrency', { url: '/preferencesAltCurrency', templateUrl: 'views/preferencesAltCurrency.html', - walletShouldBeComplete: true, needProfile: true, views: { 'main': { @@ -389,7 +384,6 @@ angular .state('about', { url: '/about', templateUrl: 'views/preferencesAbout.html', - walletShouldBeComplete: true, needProfile: true, views: { 'main': { @@ -400,7 +394,6 @@ angular .state('logs', { url: '/logs', templateUrl: 'views/preferencesLogs.html', - walletShouldBeComplete: true, needProfile: true, views: { 'main': { @@ -534,7 +527,7 @@ angular } $rootScope.$on('$stateChangeStart', function(event, toState, toParams, fromState, fromParams) { - $log.debug('Route change from:', fromState.name || '-', ' to:', toState.name); + $log.debug('Route change from:', fromState.name || '-', ' to:', toState.name); if (!profileService.profile && toState.needProfile) { diff --git a/src/js/services/feeService.js b/src/js/services/feeService.js index 280621896..72cc38245 100644 --- a/src/js/services/feeService.js +++ b/src/js/services/feeService.js @@ -1,6 +1,6 @@ 'use strict'; -angular.module('copayApp.services').factory('feeService', function($log, profileService, configService, gettextCatalog, lodash) { +angular.module('copayApp.services').factory('feeService', function($log, bwcService, profileService, configService, gettextCatalog, lodash) { var root = {}; // Constant fee options to translate @@ -19,25 +19,32 @@ angular.module('copayApp.services').factory('feeService', function($log, profile var feeLevel = root.getCurrentFeeLevel(); fc.getFeeLevels(fc.credentials.network, function(err, levels) { - if (err) - return cb({message: 'Could not get dynamic fee'}); + if (err) + return cb({ + message: 'Could not get dynamic fee' + }); - var feeLevelValue = lodash.find(levels, { level: feeLevel }); - if (!feeLevelValue || ! feeLevelValue.feePerKB) - return cb({message: 'Could not get dynamic fee for level: ' + feeLevel}); + var feeLevelValue = lodash.find(levels, { + level: feeLevel + }); + if (!feeLevelValue || !feeLevelValue.feePerKB) + return cb({ + message: 'Could not get dynamic fee for level: ' + feeLevel + }); var fee = feeLevelValue.feePerKB; - $log.debug('Dynamic fee: ' + feeLevel + ' ' + fee + ' SAT'); - return cb(null, fee); + $log.debug('Dynamic fee: ' + feeLevel + ' ' + fee + ' SAT'); + return cb(null, fee); }); - }; + }; + + root.getFeeLevels = function(cb) { + var walletClient = bwcService.getClient(); - root.getFeeLevels = function(cb) { - var fc = profileService.focusedClient; var unitName = configService.getSync().wallet.settings.unitName; - fc.getFeeLevels('livenet', function(errLivenet, levelsLivenet) { - fc.getFeeLevels('testnet', function(errTestnet, levelsTestnet) { + walletClient.getFeeLevels('livenet', function(errLivenet, levelsLivenet) { + walletClient.getFeeLevels('testnet', function(errTestnet, levelsTestnet) { if (errLivenet || errTestnet) $log.debug('Could not get dynamic fee'); else { for (var i = 0; i < 3; i++) {