bitpay card integration in home. Cache TODO

This commit is contained in:
Matias Alejo Garcia 2017-01-31 09:30:27 -03:00
commit 24c2d735cc
No known key found for this signature in database
GPG key ID: 02470DB551277AB3
4 changed files with 52 additions and 48 deletions

View file

@ -1,7 +1,7 @@
'use strict';
angular.module('copayApp.controllers').controller('tabHomeController',
function($rootScope, $timeout, $scope, $state, $stateParams, $ionicModal, $ionicScrollDelegate, $window, gettextCatalog, lodash, popupService, ongoingProcess, externalLinkService, latestReleaseService, profileService, walletService, configService, $log, platformInfo, storageService, txpModalService, appConfigService, bitpayCardService, startupService, addressbookService, feedbackService, bwcError, nextStepsService, buyAndSellService, homeIntegrationsService) {
function($rootScope, $timeout, $scope, $state, $stateParams, $ionicModal, $ionicScrollDelegate, $window, gettextCatalog, lodash, popupService, ongoingProcess, externalLinkService, latestReleaseService, profileService, walletService, configService, $log, platformInfo, storageService, txpModalService, appConfigService, startupService, addressbookService, feedbackService, bwcError, nextStepsService, buyAndSellService, homeIntegrationsService, bitpayCardService) {
var wallet;
var listeners = [];
var notifications = [];
@ -98,6 +98,10 @@ angular.module('copayApp.controllers').controller('tabHomeController',
$scope.buyAndSellItems = buyAndSellService.getLinked();
$scope.homeIntegrations = homeIntegrationsService.get();
bitpayCardService.get(function(err, cards) {
$scope.bitpayCardItems = cards;
});
configService.whenAvailable(function() {
var config = configService.getSync();
$scope.recentTransactionsEnabled = config.recentTransactions.enabled;
@ -252,29 +256,6 @@ angular.module('copayApp.controllers').controller('tabHomeController',
});
};
var bitpayCardCache = function() {
bitpayCardService.getCards(function(err, data) {
if (err) return;
if (lodash.isEmpty(data)) {
$scope.bitpayCards = null;
return;
}
$scope.bitpayCards = data;
$timeout(function() {
$scope.$digest();
}, 100);
});
// TODO
// bitpayCardService.getCardsHistoryCache(function(err, data) {
// if (err) return;
// if (lodash.isEmpty(data)) {
// $scope.cardsHistory = null;
// return;
// }
// $scope.cardsHistory = data;
// });
};
$scope.onRefresh = function() {
$timeout(function() {

View file

@ -60,8 +60,8 @@ angular.module('copayApp.services').factory('bitpayCardService', function($log,
n.eid = x.eid;
n.id = x.id;
n.lastFourDigits = x.lastFourDigits;
n.token = x.token;
n.lastFourDigits = x.lastFourDigits;
n.token = x.token;
cards.push(n);
});
@ -188,7 +188,7 @@ angular.module('copayApp.services').factory('bitpayCardService', function($log,
// storageService.setBitpayDebitCardHistory(cardId, data, cb);
// };
//
root.remove = function(cardId, cb) {
storageService.removeBitpayDebitCard(bitpayService.getEnvironment().network, cardId, function(err) {
if (err) {
@ -210,6 +210,28 @@ angular.module('copayApp.services').factory('bitpayCardService', function($log,
});
};
root.get = function(cb) {
root.getCards(function(err, cards) {
if (err) return;
if (lodash.isEmpty(cards)) {
return cb();
}
// TODO
// bitpayCardService.getCardsHistoryCache(function(err, data) {
// if (err) return;
// if (lodash.isEmpty(data)) {
// $scope.cardsHistory = null;
// return;
// }
// $scope.cardsHistory = data;
// });
return cb(null, cards);
});
};
/*
* CONSTANTS
*/