Remove Storage and Profile, Move folders, add EncryptedInsightStorage

This commit is contained in:
Esteban Ordano 2014-10-24 12:24:44 -03:00
commit 61b677498b
20 changed files with 374 additions and 1067 deletions

View file

@ -195,20 +195,19 @@ angular.module('copayApp.services')
root.rebindWallets = function($scope, iden) {
_.each(iden.listWallets(), function(winfo) {
var w = iden.getOpenWallet(winfo.id);
preconditions.checkState(w);
root.installWalletHandlers($scope, w);
_.each(iden.listWallets(), function(wallet) {
preconditions.checkState(wallet);
root.installWalletHandlers($scope, wallet);
});
};
root.setFocusedWallet = function(w) {
if (!_.isObject(w))
w = $rootScope.iden.getOpenWallet(w);
w = $rootScope.iden.getWalletById(w);
preconditions.checkState(w && _.isObject(w));
$rootScope.wallet = w;
$rootScope.iden.profile.setLastFocusedTs(w.id, function() {
w.updateTimestamp(new Date().getTime(), function() {
root.redirIfLogged();
root.updateBalance(w, function() {
$rootScope.$digest();
@ -226,8 +225,7 @@ angular.module('copayApp.services')
}
};
// On the focused wallet
// On the focused wallet
root.updateAddressList = function(wid) {
if (!wid || root.isFocusedWallet(wid)) {
@ -396,7 +394,7 @@ angular.module('copayApp.services')
$rootScope.iden.deleteWallet(w.id, function() {
notification.info('Wallet deleted', $filter('translate')('Wallet deleted'));
$rootScope.wallet = null;
var lastFocused = $rootScope.iden.profile.getLastFocusedWallet();
var lastFocused = $rootScope.iden.getLastFocusedWallet();
root.bindProfile($scope, $rootScope.iden, lastFocused);
});
};

View file

@ -4,32 +4,17 @@ angular.module('copayApp.services')
.factory('identityService', function($rootScope, $location, pluginManager, controllerUtils) {
var root = {};
root.check = function (scope) {
copay.Identity.anyProfile({
pluginManager: pluginManager,
}, function(anyProfile) {
copay.Identity.anyWallet({
pluginManager: pluginManager,
}, function(anyWallet) {
scope.retreiving = false;
scope.anyProfile = anyProfile ? true : false;
scope.anyWallet = anyWallet ? true : false;
if (!scope.anyProfile) {
$location.path('/createProfile');
}
});
});
};
root.create = function (scope, form) {
copay.Identity.create(form.email.$modelValue, form.password.$modelValue, {
copay.Identity.create({
email: form.email.$modelValue,
password: form.password.$modelValue,
pluginManager: pluginManager,
network: config.network,
networkName: config.networkName,
walletDefaults: config.wallet,
passphraseConfig: config.passphraseConfig,
}, function(err, iden, firstWallet) {
}, function(err, iden) {
var firstWallet = iden.getLastFocusedWallet();
controllerUtils.bindProfile(scope, iden, firstWallet);
scope.loading = false;
});
@ -37,19 +22,22 @@ angular.module('copayApp.services')
root.open = function (scope, form) {
copay.Identity.open(form.email.$modelValue, form.password.$modelValue, {
copay.Identity.open({
email: form.email.$modelValue,
password: form.password.$modelValue,
pluginManager: pluginManager,
network: config.network,
networkName: config.networkName,
walletDefaults: config.wallet,
passphraseConfig: config.passphraseConfig,
}, function(err, iden, lastFocusedWallet) {
}, function(err, iden) {
if (err && !iden) {
console.log('Error:' + err)
controllerUtils.onErrorDigest(
scope, (err.toString() || '').match('PNOTFOUND') ? 'Profile not found' : 'Unknown error');
} else {
controllerUtils.bindProfile(scope, iden, lastFocusedWallet);
var firstWallet = iden.getLastFocusedWallet();
controllerUtils.bindProfile(scope, iden, firstWallet);
}
scope.loading = false;
});

View file

@ -1,18 +1,19 @@
'use strict';
var MINS_IN_HOUR = 60;
var MILLIS_IN_SECOND = 1000;
var RateService = function(request) {
this.isAvailable = false;
this.UNAVAILABLE_ERROR = 'Service is not available - check for service.isAvailable or use service.whenAvailable';
this.SAT_TO_BTC = 1 / 1e8;
this.BTC_TO_SAT = 1e8;
var MINS_IN_HOUR = 60;
var MILLIS_IN_SECOND = 1000;
var rateServiceConfig = config.rate;
var updateFrequencySeconds = rateServiceConfig.updateFrequencySeconds || 60 * MINS_IN_HOUR;
var rateServiceUrl = rateServiceConfig.url || 'https://bitpay.com/api/rates';
this.queued = [];
this.alternatives = [];
var that = this;
var self = this;
var backoffSeconds = 5;
var retrieve = function() {
request.get({
@ -27,15 +28,15 @@ var RateService = function(request) {
var rates = {};
listOfCurrencies.forEach(function(element) {
rates[element.code] = element.rate;
that.alternatives.push({
self.alternatives.push({
name: element.name,
isoCode: element.code,
rate: element.rate
});
});
that.isAvailable = true;
that.rates = rates;
that.queued.forEach(function(callback) {
self.isAvailable = true;
self.rates = rates;
self.queued.forEach(function(callback) {
setTimeout(callback, 1);
});
setTimeout(retrieve, updateFrequencySeconds * MILLIS_IN_SECOND);