Caching txs
This commit is contained in:
parent
c223de2c63
commit
48e921e7df
5 changed files with 59 additions and 34 deletions
|
|
@ -1,10 +1,12 @@
|
||||||
'use strict';
|
'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 amount;
|
||||||
var currency;
|
var currency;
|
||||||
|
|
||||||
|
$scope.isCordova = platformInfo.isCordova;
|
||||||
|
|
||||||
var showErrorAndBack = function(err) {
|
var showErrorAndBack = function(err) {
|
||||||
$scope.sendStatus = '';
|
$scope.sendStatus = '';
|
||||||
$log.error(err);
|
$log.error(err);
|
||||||
|
|
|
||||||
|
|
@ -13,14 +13,7 @@ angular.module('copayApp.controllers').controller('glideraController',
|
||||||
|
|
||||||
$scope.account['token'] = data.token;
|
$scope.account['token'] = data.token;
|
||||||
$scope.account['status'] = data.status;
|
$scope.account['status'] = data.status;
|
||||||
$scope.account['price'] = {};
|
$scope.account['txs'] = data.txs;
|
||||||
|
|
||||||
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;
|
|
||||||
});
|
|
||||||
|
|
||||||
$timeout(function() {
|
$timeout(function() {
|
||||||
$scope.$digest();
|
$scope.$digest();
|
||||||
|
|
@ -46,6 +39,8 @@ angular.module('copayApp.controllers').controller('glideraController',
|
||||||
popupService.showAlert('Authorisation error', err);
|
popupService.showAlert('Authorisation error', err);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
$scope.account['token'] = data.token;
|
||||||
|
$scope.account['status'] = data.status;
|
||||||
init();
|
init();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,12 @@
|
||||||
'use strict';
|
'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 amount;
|
||||||
var currency;
|
var currency;
|
||||||
|
|
||||||
|
$scope.isCordova = platformInfo.isCordova;
|
||||||
|
|
||||||
var showErrorAndBack = function(err) {
|
var showErrorAndBack = function(err) {
|
||||||
$scope.sendStatus = '';
|
$scope.sendStatus = '';
|
||||||
$log.error(err);
|
$log.error(err);
|
||||||
|
|
|
||||||
|
|
@ -353,11 +353,15 @@ console.log('[glideraService.js:333]',data); //TODO
|
||||||
if (lodash.isString(permissions)) permissions = JSON.parse(permissions);
|
if (lodash.isString(permissions)) permissions = JSON.parse(permissions);
|
||||||
storageService.getGlideraStatus(credentials.NETWORK, function(err, status) {
|
storageService.getGlideraStatus(credentials.NETWORK, function(err, status) {
|
||||||
if (lodash.isString(status)) status = JSON.parse(status);
|
if (lodash.isString(status)) status = JSON.parse(status);
|
||||||
buyAndSellService.updateLink('glidera', true);
|
storageService.getGlideraTxs(credentials.NETWORK, function(err, txs) {
|
||||||
return cb(null, {
|
if (lodash.isString(txs)) txs = JSON.parse(txs);
|
||||||
token: accessToken,
|
buyAndSellService.updateLink('glidera', true);
|
||||||
permissions: permissions,
|
return cb(null, {
|
||||||
status: status
|
token: accessToken,
|
||||||
|
permissions: permissions,
|
||||||
|
status: status,
|
||||||
|
txs: txs
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
@ -371,31 +375,41 @@ console.log('[glideraService.js:333]',data); //TODO
|
||||||
if (err) return;
|
if (err) return;
|
||||||
storageService.setGlideraPermissions(credentials.NETWORK, JSON.stringify(permissions), function() {});
|
storageService.setGlideraPermissions(credentials.NETWORK, JSON.stringify(permissions), function() {});
|
||||||
data.permissions = permissions;
|
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) {
|
root.getStatus(accessToken, function(err, status) {
|
||||||
data.status = status;
|
data.status = status;
|
||||||
storageService.setGlideraStatus(credentials.NETWORK, JSON.stringify(status), function() {});
|
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;
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -271,6 +271,18 @@ angular.module('copayApp.services')
|
||||||
storage.remove('glideraStatus-' + network, cb);
|
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) {
|
root.setCoinbaseRefreshToken = function(network, token, cb) {
|
||||||
storage.set('coinbaseRefreshToken-' + network, token, cb);
|
storage.set('coinbaseRefreshToken-' + network, token, cb);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue