Improved bitpay account pairing and management of paired state and data.

This commit is contained in:
Andy Phillipson 2017-01-06 12:11:47 -05:00
commit 63bc3d8f63
23 changed files with 691 additions and 208 deletions

View file

@ -1,6 +1,6 @@
'use strict';
angular.module('copayApp.controllers').controller('tabSettingsController', function($scope, appConfigService, $log, lodash, uxLanguage, platformInfo, profileService, feeService, configService, externalLinkService, bitpayCardService, storageService, glideraService, coinbaseService, gettextCatalog, buyAndSellService) {
angular.module('copayApp.controllers').controller('tabSettingsController', function($scope, appConfigService, $ionicModal, $log, lodash, uxLanguage, platformInfo, profileService, feeService, configService, externalLinkService, bitpayAccountService, bitpayCardService, storageService, glideraService, gettextCatalog) {
var updateConfig = function() {
var isCordova = platformInfo.isCordova;
@ -25,12 +25,27 @@ angular.module('copayApp.controllers').controller('tabSettingsController', funct
isoCode: config.wallet.settings.alternativeIsoCode
};
// TODO move this to a generic service
bitpayCardService.getCards(function(err, cards) {
$scope.bitpayCardEnabled = config.bitpayCard.enabled;
$scope.glideraEnabled = config.glidera.enabled && !isWindowsPhoneApp;
bitpayAccountService.getAccounts(function(err, data) {
if (err) $log.error(err);
$scope.bitpayCards = cards && cards.length > 0;
$scope.bitpayAccounts = !lodash.isEmpty(data);
});
if ($scope.bitpayCardEnabled) {
bitpayCardService.getBitpayDebitCards(function(err, cards) {
if (err) $log.error(err);
$scope.bitpayCards = cards && cards.length > 0;
});
}
if ($scope.glideraEnabled) {
storageService.getGlideraToken(glideraService.getEnvironment(), function(err, token) {
if (err) $log.error(err);
$scope.glideraToken = token;
});
}
});
};