diff --git a/src/js/controllers/buyGlidera.js b/src/js/controllers/buyGlidera.js index 475534806..7839685cc 100644 --- a/src/js/controllers/buyGlidera.js +++ b/src/js/controllers/buyGlidera.js @@ -1,10 +1,12 @@ 'use strict'; -angular.module('copayApp.controllers').controller('buyGlideraController', function($scope, $log, $state, $timeout, $ionicHistory, lodash, glideraService, popupService, profileService, ongoingProcess, walletService) { +angular.module('copayApp.controllers').controller('buyGlideraController', function($scope, $log, $state, $timeout, $ionicHistory, lodash, glideraService, popupService, profileService, ongoingProcess, walletService, platformInfo) { var amount; var currency; + $scope.isCordova = platformInfo.isCordova; + var showErrorAndBack = function(err) { $scope.sendStatus = ''; $log.error(err); diff --git a/src/js/controllers/glidera.js b/src/js/controllers/glidera.js index de903d15b..7a2609430 100644 --- a/src/js/controllers/glidera.js +++ b/src/js/controllers/glidera.js @@ -13,14 +13,7 @@ angular.module('copayApp.controllers').controller('glideraController', $scope.account['token'] = data.token; $scope.account['status'] = data.status; - $scope.account['price'] = {}; - - glideraService.buyPrice($scope.account.token, {qty: 1}, function(err, buy) { - $scope.account.price['buy'] = buy.price; - }); - glideraService.sellPrice($scope.account.token, {qty: 1}, function(err, sell) { - $scope.account.price['sell'] = sell.price; - }); + $scope.account['txs'] = data.txs; $timeout(function() { $scope.$digest(); @@ -46,6 +39,8 @@ angular.module('copayApp.controllers').controller('glideraController', popupService.showAlert('Authorisation error', err); return; } + $scope.account['token'] = data.token; + $scope.account['status'] = data.status; init(); }); }; diff --git a/src/js/controllers/sellGlidera.js b/src/js/controllers/sellGlidera.js index c99c2f478..3028e0df3 100644 --- a/src/js/controllers/sellGlidera.js +++ b/src/js/controllers/sellGlidera.js @@ -1,10 +1,12 @@ 'use strict'; -angular.module('copayApp.controllers').controller('sellGlideraController', function($scope, $log, $state, $timeout, $ionicHistory, lodash, glideraService, popupService, profileService, ongoingProcess, walletService, configService) { +angular.module('copayApp.controllers').controller('sellGlideraController', function($scope, $log, $state, $timeout, $ionicHistory, lodash, glideraService, popupService, profileService, ongoingProcess, walletService, configService, platformInfo) { var amount; var currency; + $scope.isCordova = platformInfo.isCordova; + var showErrorAndBack = function(err) { $scope.sendStatus = ''; $log.error(err); diff --git a/src/js/services/glideraService.js b/src/js/services/glideraService.js index 0fd2e1b0a..60997175f 100644 --- a/src/js/services/glideraService.js +++ b/src/js/services/glideraService.js @@ -353,11 +353,15 @@ console.log('[glideraService.js:333]',data); //TODO if (lodash.isString(permissions)) permissions = JSON.parse(permissions); storageService.getGlideraStatus(credentials.NETWORK, function(err, status) { if (lodash.isString(status)) status = JSON.parse(status); - buyAndSellService.updateLink('glidera', true); - return cb(null, { - token: accessToken, - permissions: permissions, - status: status + storageService.getGlideraTxs(credentials.NETWORK, function(err, txs) { + if (lodash.isString(txs)) txs = JSON.parse(txs); + buyAndSellService.updateLink('glidera', true); + return cb(null, { + token: accessToken, + permissions: permissions, + status: status, + txs: txs + }); }); }); }); @@ -371,31 +375,41 @@ console.log('[glideraService.js:333]',data); //TODO if (err) return; storageService.setGlideraPermissions(credentials.NETWORK, JSON.stringify(permissions), function() {}); data.permissions = permissions; + + data.price = {}; + root.buyPrice(accessToken, {qty: 1}, function(err, buy) { + data.price['buy'] = buy.price; + }); + root.sellPrice(accessToken, {qty: 1}, function(err, sell) { + data.price['sell'] = sell.price; + }); + root.getStatus(accessToken, function(err, status) { data.status = status; storageService.setGlideraStatus(credentials.NETWORK, JSON.stringify(status), function() {}); - - root.getLimits(accessToken, function(err, limits) { - data.limits = limits; - - if (permissions.transaction_history) { - root.getTransactions(accessToken, function(err, txs) { - data.txs = txs; - }); - } - - if (permissions.view_email_address) { - root.getEmail(accessToken, function(err, email) { - data.email = email; - }); - } - if (permissions.personal_info) { - root.getPersonalInfo(accessToken, function(err, info) { - data.personalInfo = info; - }); - } - }); }); + + root.getLimits(accessToken, function(err, limits) { + data.limits = limits; + }); + + if (permissions.transaction_history) { + root.getTransactions(accessToken, function(err, txs) { + storageService.setGlideraTxs(credentials.NETWORK, JSON.stringify(txs), function() {}); + data.txs = txs; + }); + } + + if (permissions.view_email_address) { + root.getEmail(accessToken, function(err, email) { + data.email = email; + }); + } + if (permissions.personal_info) { + root.getPersonalInfo(accessToken, function(err, info) { + data.personalInfo = info; + }); + } }); }); }; diff --git a/src/js/services/storageService.js b/src/js/services/storageService.js index 3080b1b52..60510d98f 100644 --- a/src/js/services/storageService.js +++ b/src/js/services/storageService.js @@ -271,6 +271,18 @@ angular.module('copayApp.services') storage.remove('glideraStatus-' + network, cb); }; + root.setGlideraTxs = function(network, txs, cb) { + storage.set('glideraTxs-' + network, txs, cb); + }; + + root.getGlideraTxs = function(network, cb) { + storage.get('glideraTxs-' + network, cb); + }; + + root.removeGlideraTxs = function(network, cb) { + storage.remove('glideraTxs-' + network, cb); + }; + root.setCoinbaseRefreshToken = function(network, token, cb) { storage.set('coinbaseRefreshToken-' + network, token, cb); };