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

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