refactor profileService

This commit is contained in:
Matias Alejo Garcia 2016-06-06 12:21:15 -03:00
commit 4865ea8ad8
No known key found for this signature in database
GPG key ID: 02470DB551277AB3
9 changed files with 241 additions and 204 deletions

View file

@ -24,21 +24,6 @@ angular.module('copayApp.services')
}, cb);
};
var encryptOnMobile = function(text, cb) {
// UUID encryption is disabled.
return cb(null, text);
//
// getUUID(function(uuid) {
// if (uuid) {
// $log.debug('Encrypting profile');
// text = sjcl.encrypt(uuid, text);
// }
// return cb(null, text);
// });
};
var decryptOnMobile = function(text, cb) {
var json;
try {
@ -107,18 +92,14 @@ angular.module('copayApp.services')
};
root.storeNewProfile = function(profile, cb) {
encryptOnMobile(profile.toObj(), function(err, x) {
storage.create('profile', x, cb);
});
storage.create('profile', profile.toObj(), cb);
};
root.storeProfile = function(profile, cb) {
encryptOnMobile(profile.toObj(), function(err, x) {
storage.set('profile', x, cb);
});
storage.set('profile', profile.toObj(), cb);
};
root.storeProfileThrottled = lodash.throttle(root.storeProfile, 5000);
root.storeProfileThrottled = lodash.throttle(root.storeProfile, 5000);
root.getProfile = function(cb) {
storage.get('profile', function(err, str) {
@ -293,5 +274,17 @@ angular.module('copayApp.services')
storage.remove('coinbaseTxs-' + network, cb);
};
root.removeAllWalletData = function(walletId, cb) {
storageService.clearLastAddress(walletId, function(err) {
if (err) return cb(err);
storageService.removeTxHistory(walletId, function(err) {
if (err) return cb(err);
storageService.clearBackupFlag(walletId, function(err) {
return cb(err);
});
});
});
};
return root;
});