Adds three levels of dynamic fees

This commit is contained in:
Gustavo Maximiliano Cortez 2015-07-24 12:11:07 -03:00
commit 5742dee340
10 changed files with 241 additions and 110 deletions

View file

@ -1,6 +1,6 @@
'use strict';
angular.module('copayApp.controllers').controller('indexController', function($rootScope, $scope, $log, $filter, $timeout, lodash, go, profileService, configService, isCordova, rateService, storageService, addressService, gettextCatalog, gettext, amMoment, nodeWebkit, addonManager) {
angular.module('copayApp.controllers').controller('indexController', function($rootScope, $scope, $log, $filter, $timeout, lodash, go, profileService, configService, isCordova, rateService, storageService, addressService, gettextCatalog, gettext, amMoment, nodeWebkit, addonManager, feeService) {
var self = this;
self.isCordova = isCordova;
self.onGoingProcess = {};
@ -278,6 +278,7 @@ angular.module('copayApp.controllers').controller('indexController', function($r
}
$log.debug('Wallet Status:', walletStatus);
self.setPendingTxps(walletStatus.pendingTxps);
self.setFees();
// Status Shortcuts
self.walletName = walletStatus.wallet.name;
@ -305,6 +306,22 @@ angular.module('copayApp.controllers').controller('indexController', function($r
});
};
self.setCurrentFeeLevel = function(level) {
self.currentFeeLevel = level || configService.getSync().wallet.settings.feeLevel || 'priority';
};
self.setFees = function() {
var fc = profileService.focusedClient;
if (!fc) return;
$timeout(function() {
feeService.getFeeLevels(function(levels) {
self.feeLevels = levels;
self.setCurrentFeeLevel();
$rootScope.$apply();
});
});
};
self.updateBalance = function() {
var fc = profileService.focusedClient;
$timeout(function() {
@ -801,6 +818,10 @@ angular.module('copayApp.controllers').controller('indexController', function($r
});
});
$rootScope.$on('Local/FeeLevelUpdated', function(event, level) {
self.setCurrentFeeLevel(level);
});
$rootScope.$on('Local/ProfileBound', function() {
storageService.getRemotePrefsStoredFlag(function(err, val) {
if (err || val) return;