buyAndSell services + nextSteps
This commit is contained in:
parent
19b3d9bb15
commit
d85da2cc45
15 changed files with 340 additions and 192 deletions
14
src/js/controllers/buyAndSellCardController.js
Normal file
14
src/js/controllers/buyAndSellCardController.js
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('buyAndSellCardController', function($scope, nextStepsService, $ionicScrollDelegate, buyAndSellService) {
|
||||
|
||||
$scope.services = buyAndSellService.getLinked();
|
||||
|
||||
$scope.toggle = function() {
|
||||
$scope.hide = !$scope.hide;
|
||||
$timeout(function() {
|
||||
$ionicScrollDelegate.resize();
|
||||
$scope.$apply();
|
||||
}, 10);
|
||||
};
|
||||
});
|
||||
|
|
@ -1,14 +1,11 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('buyandsellController', function($scope, $ionicHistory, configService) {
|
||||
angular.module('copayApp.controllers').controller('buyandsellController', function($scope, $ionicHistory, buyAndSellService, lodash) {
|
||||
|
||||
$scope.$on("$ionicView.beforeEnter", function(event, data) {
|
||||
configService.whenAvailable(function(config) {
|
||||
$scope.isCoinbaseEnabled = config.coinbaseV2;
|
||||
$scope.isGlideraEnabled = config.glidera.enabled;
|
||||
$scope.services = buyAndSellService.get();
|
||||
|
||||
if (!$scope.isCoinbaseEnabled && !$scope.isGlideraEnabled)
|
||||
$ionicHistory.goBack();
|
||||
});
|
||||
if (lodash.isEmpty($scope.services))
|
||||
$ionicHistory.goBack();
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -112,7 +112,6 @@ angular.module('copayApp.controllers').controller('coinbaseController', function
|
|||
|
||||
var self = this;
|
||||
$scope.$on("$ionicView.beforeEnter", function(event, data) {
|
||||
coinbaseService.setCredentials();
|
||||
if (data.stateParams && data.stateParams.code) {
|
||||
coinbaseService.getStoredToken(function(at) {
|
||||
if (!at) self.submitOauthCode(data.stateParams.code);
|
||||
|
|
|
|||
16
src/js/controllers/nextStepsController.js
Normal file
16
src/js/controllers/nextStepsController.js
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('nextStepsController', function($scope, nextStepsService, $ionicScrollDelegate, $timeout) {
|
||||
|
||||
$scope.hide = false;
|
||||
$scope.services = nextStepsService.get();
|
||||
|
||||
$scope.toggle = function() {
|
||||
$scope.hide = !$scope.hide;
|
||||
$timeout(function() {
|
||||
$ionicScrollDelegate.resize();
|
||||
$scope.$apply();
|
||||
}, 10);
|
||||
};
|
||||
|
||||
});
|
||||
|
|
@ -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, coinbaseService) {
|
||||
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) {
|
||||
var wallet;
|
||||
var listeners = [];
|
||||
var notifications = [];
|
||||
|
|
@ -83,10 +83,7 @@ angular.module('copayApp.controllers').controller('tabHomeController',
|
|||
var wallet = profileService.getWallet(walletId);
|
||||
updateWallet(wallet);
|
||||
if ($scope.recentTransactionsEnabled) getNotifications();
|
||||
if ($scope.coinbaseEnabled && type == 'NewBlock' && n && n.data && n.data.network == 'livenet') {
|
||||
// Update Coinbase
|
||||
coinbaseService.updatePendingTransactions();
|
||||
}
|
||||
|
||||
}),
|
||||
$rootScope.$on('Local/TxAction', function(e, walletId) {
|
||||
$log.debug('Got action for wallet ' + walletId);
|
||||
|
|
@ -96,31 +93,22 @@ angular.module('copayApp.controllers').controller('tabHomeController',
|
|||
})
|
||||
];
|
||||
|
||||
|
||||
$scope.nextStepsItems = nextStepsService.get();
|
||||
$scope.buyAndSellItems = buyAndSellService.getLinked();
|
||||
|
||||
console.log('[tab-home.js.99]', $scope.buyAndSellItems); //TODO
|
||||
|
||||
configService.whenAvailable(function() {
|
||||
nextStep(function() {
|
||||
var config = configService.getSync();
|
||||
var isWindowsPhoneApp = platformInfo.isWP && platformInfo.isCordova;
|
||||
var config = configService.getSync();
|
||||
$scope.recentTransactionsEnabled = config.recentTransactions.enabled;
|
||||
if ($scope.recentTransactionsEnabled) getNotifications();
|
||||
|
||||
$scope.glideraEnabled = config.glidera.enabled && !isWindowsPhoneApp;
|
||||
$scope.coinbaseEnabled = config.coinbaseV2 && !isWindowsPhoneApp;
|
||||
$scope.amazonEnabled = config.amazon.enabled;
|
||||
$scope.bitpayCardEnabled = config.bitpayCard.enabled;
|
||||
|
||||
var buyAndSellEnabled = !$scope.externalServices.BuyAndSell && ($scope.glideraEnabled || $scope.coinbaseEnabled);
|
||||
var amazonEnabled = !$scope.externalServices.AmazonGiftCards && $scope.amazonEnabled;
|
||||
var bitpayCardEnabled = !$scope.externalServices.BitpayCard && $scope.bitpayCardEnabled;
|
||||
|
||||
$scope.nextStepEnabled = buyAndSellEnabled || amazonEnabled || bitpayCardEnabled;
|
||||
$scope.recentTransactionsEnabled = config.recentTransactions.enabled;
|
||||
|
||||
if ($scope.recentTransactionsEnabled) getNotifications();
|
||||
|
||||
if ($scope.bitpayCardEnabled) bitpayCardCache();
|
||||
$timeout(function() {
|
||||
$ionicScrollDelegate.resize();
|
||||
$scope.$apply();
|
||||
}, 10);
|
||||
});
|
||||
if ($scope.bitpayCardEnabled) bitpayCardCache();
|
||||
$timeout(function() {
|
||||
$ionicScrollDelegate.resize();
|
||||
$scope.$apply();
|
||||
}, 10);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
@ -213,7 +201,7 @@ angular.module('copayApp.controllers').controller('tabHomeController',
|
|||
walletService.getStatus(wallet, {}, function(err, status) {
|
||||
if (err) {
|
||||
|
||||
wallet.error = (err === 'WALLET_NOT_REGISTERED') ? gettextCatalog.getString('Wallet not registered') : bwcError.msg(err);
|
||||
wallet.error = (err === 'WALLET_NOT_REGISTERED') ? gettextCatalog.getString('Wallet not registered') : bwcError.msg(err);
|
||||
|
||||
$log.error(err);
|
||||
} else {
|
||||
|
|
@ -265,25 +253,6 @@ angular.module('copayApp.controllers').controller('tabHomeController',
|
|||
});
|
||||
};
|
||||
|
||||
var nextStep = function(cb) {
|
||||
var i = 0;
|
||||
var services = ['AmazonGiftCards', 'BitpayCard', 'BuyAndSell'];
|
||||
lodash.each(services, function(service) {
|
||||
storageService.getNextStep(service, function(err, value) {
|
||||
$scope.externalServices[service] = value == 'true' ? true : false;
|
||||
if (++i == services.length) return cb();
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
$scope.shouldHideNextSteps = function() {
|
||||
$scope.hideNextSteps = !$scope.hideNextSteps;
|
||||
$timeout(function() {
|
||||
$ionicScrollDelegate.resize();
|
||||
$scope.$apply();
|
||||
}, 10);
|
||||
};
|
||||
|
||||
var bitpayCardCache = function() {
|
||||
bitpayCardService.getCards(function(err, data) {
|
||||
if (err) return;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue