mirror of https://github.com/BTCPrivate/copay.git
fix set global address book
This commit is contained in:
parent
0d81cf8e9c
commit
1d3d0ff5ed
|
@ -338,12 +338,16 @@ angular.module('copayApp.services')
|
||||||
};
|
};
|
||||||
|
|
||||||
root.setMetaData = function(walletClient, addressBook, historyCache, cb) {
|
root.setMetaData = function(walletClient, addressBook, historyCache, cb) {
|
||||||
|
storageService.getAddressbook(walletClient.credentials.network, function(err, localAddressBook) {
|
||||||
storageService.setAddressbook(walletClient.credentials.network, JSON.stringify(addressBook), function(err) {
|
localAddressBook = JSON.parse(localAddressBook);
|
||||||
if (err) return cb(err);
|
if (!localAddressBook) localAddressBook = {};
|
||||||
storageService.setTxHistory(JSON.stringify(historyCache), walletClient.credentials.walletId, function(err) {
|
addressBook = lodash.merge(addressBook, localAddressBook);
|
||||||
|
storageService.setAddressbook(walletClient.credentials.network, JSON.stringify(addressBook), function(err) {
|
||||||
if (err) return cb(err);
|
if (err) return cb(err);
|
||||||
return cb(null);
|
storageService.setTxHistory(JSON.stringify(historyCache), walletClient.credentials.walletId, function(err) {
|
||||||
|
if (err) return cb(err);
|
||||||
|
return cb(null);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -397,12 +401,11 @@ angular.module('copayApp.services')
|
||||||
|
|
||||||
str = JSON.parse(str);
|
str = JSON.parse(str);
|
||||||
|
|
||||||
var addressBook = str.addressBook || [];
|
var addressBook = str.addressBook || {};
|
||||||
var historyCache = str.historyCache || [];
|
var historyCache = str.historyCache || [];
|
||||||
|
|
||||||
root.setMetaData(walletClient, addressBook, historyCache, function(err) {
|
root.setMetaData(walletClient, addressBook, historyCache, function(err) {
|
||||||
if (err) console.log(err);
|
if (err) console.log(err);
|
||||||
|
|
||||||
root._addWalletClient(walletClient, opts, cb);
|
root._addWalletClient(walletClient, opts, cb);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue