Merge pull request #96 from cmgustavo/ref/design-25

Address book as a view (not modal)
This commit is contained in:
Gustavo Maximiliano Cortez 2016-09-13 09:50:51 -03:00 committed by GitHub
commit c90e58a958
14 changed files with 336 additions and 243 deletions

View file

@ -3,12 +3,16 @@
angular.module('copayApp.services').factory('addressbookService', function(bitcore, storageService, lodash) {
var root = {};
root.getLabel = function(addr, cb) {
root.get = function(addr, cb) {
storageService.getAddressbook('testnet', function(err, ab) {
if (ab && ab[addr]) return cb(ab[addr]);
if (err) return cb(err);
if (ab) ab = JSON.parse(ab);
if (ab && ab[addr]) return cb(null, ab[addr]);
storageService.getAddressbook('livnet', function(err, ab) {
if (ab && ab[addr]) return cb(ab[addr]);
storageService.getAddressbook('livenet', function(err, ab) {
if (err) return cb(err);
if (ab) ab = JSON.parse(ab);
if (ab && ab[addr]) return cb(null, ab[addr]);
return cb();
});
});
@ -38,7 +42,7 @@ angular.module('copayApp.services').factory('addressbookService', function(bitco
ab = ab || {};
if (lodash.isArray(ab)) ab = {}; // No array
if (ab[entry.address]) return cb('Entry already exist');
ab[entry.address] = entry.label;
ab[entry.address] = entry;
storageService.setAddressbook(network, JSON.stringify(ab), function(err, ab) {
if (err) return cb('Error adding new entry');
root.list(function(err, ab) {