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
This commit is contained in:
Gabriel Edgardo Bazán 2016-04-13 17:46:25 +02:00 committed by Gustavo Maximiliano Cortez
commit b720821d4e
8 changed files with 34 additions and 37 deletions

View file

@ -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",

View file

@ -28,7 +28,7 @@
<div translate>Create, join or import</div>
</a>
</li>
<li ng-show="index.glideraEnabled">
<li ng-show="index.glideraEnabled && index.isComplete">
<a ng-click="sidebar.closeMenu(); $root.go('glidera')" class="oh">
<i class="icon-arrow-right3 size-18 right m10t vm"></i>
<i class="icon-bank size-24 icon vm"></i>

View file

@ -1,5 +1,5 @@
<div
class="topbar-container"
<div
class="topbar-container"
ng-include="'views/includes/topbar.html'"
ng-init="titleSection='Bitcoin Network Fee Policy'; goBackToState = 'preferencesGlobal'; noColor = true">
</div>
@ -21,8 +21,8 @@
</div>
</div>
</div>
<ul class="no-bullet m0">
<li ng-repeat="fee in (index.network == 'livenet' ? prefFee.feeLevels.livenet : prefFee.feeLevels.testnet)"
<ul class="no-bullet m0">
<li ng-repeat="fee in prefFee.feeLevels.livenet"
ng-click="prefFee.save(fee.level)">
{{prefFee.feeOpts[fee.level]|translate}}
<i class="fi-check size-16 right" ng-show="prefFee.currentFeeLevel == fee.level"></i>
@ -30,8 +30,7 @@
</ul>
<div class="row m20t">
<div class="text-gray size-12 text-center" ng-repeat="fee in (index.network == 'livenet' ? prefFee.feeLevels.livenet :
prefFee.feeLevels.testnet)" ng-if="fee.level == prefFee.currentFeeLevel">
<div class="text-gray size-12 text-center" ng-repeat="fee in prefFee.feeLevels.livenet" ng-if="fee.level == prefFee.currentFeeLevel">
<div ng-show="fee.nbBlocks">
<span translate>Average confirmation time: {{fee.nbBlocks * 10}} minutes</span>.
</div>

View file

@ -78,7 +78,7 @@
<div translate>About Copay</div>
</li>
</ul>
<div ng-show="prefGlobal.usePushNotifications && !PNEnabledByUser && isIOS">
<div ng-show="prefGlobal.usePushNotifications && !PNEnabledByUser && isIOSApp">
<div class="text-centered text-gray size-12 m10" translate>Push notifications for Copay are currently disabled. Enable them in the Settings app.</div>
<ul class="no-bullet m0" ng-click="prefGlobal.openSettings()">
<li ng-style="{'color':index.backgroundColor}" translate>Open Settings app</li>

View file

@ -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() {

View file

@ -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;
});

View file

@ -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) {

View file

@ -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++) {