Fix - 253 - Removing contact from Address Book feature not functional
This commit is contained in:
parent
5a6139e6dc
commit
16a484c57c
3 changed files with 20 additions and 7 deletions
|
|
@ -40,12 +40,13 @@ angular.module('copayApp.controllers').controller('addressbookViewController', f
|
|||
}, 100);
|
||||
};
|
||||
|
||||
$scope.remove = function(addr) {
|
||||
$scope.remove = function(addressbookEntry) {
|
||||
var title = gettextCatalog.getString('Warning!');
|
||||
var message = gettextCatalog.getString('Are you sure you want to delete this contact?');
|
||||
popupService.showConfirm(title, message, null, null, function(res) {
|
||||
if (!res) return;
|
||||
addressbookService.remove(addr, function(err, ab) {
|
||||
|
||||
addressbookService.remove(addressbookEntry, function(err, ab) {
|
||||
if (err) {
|
||||
popupService.showAlert(gettextCatalog.getString('Error'), err);
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -64,16 +64,28 @@ angular.module('copayApp.services').factory('addressbookService', function($log,
|
|||
});
|
||||
};
|
||||
|
||||
root.remove = function(addr, cb) {
|
||||
var network = getNetwork(addr);
|
||||
root.remove = function(entry, cb) {
|
||||
|
||||
// The entry is in bitcoin address, so I get the legacy one, and I operate.
|
||||
if (entry.coin == 'bch') {
|
||||
var a = entry.address;
|
||||
if (entry.address.indexOf('bitcoincash:') < 0) {
|
||||
a = 'bitcoincash:' + a;
|
||||
}
|
||||
entry.address = bitcoinCashJsService.readAddress(a).legacy;
|
||||
} else {
|
||||
entry.address = entry.address;
|
||||
}
|
||||
|
||||
var network = getNetwork(entry.address);
|
||||
if (lodash.isEmpty(network)) return cb('Not valid bitcoin address');
|
||||
storageService.getAddressbook(network, function(err, ab) {
|
||||
if (err) return cb(err);
|
||||
if (ab) ab = JSON.parse(ab);
|
||||
ab = ab || {};
|
||||
if (lodash.isEmpty(ab)) return cb('Addressbook is empty');
|
||||
if (!ab[addr]) return cb('Entry does not exist');
|
||||
delete ab[addr];
|
||||
if (!ab[entry.coin + entry.address]) return cb('Entry does not exist');
|
||||
delete ab[entry.coin + entry.address];
|
||||
storageService.setAddressbook(network, JSON.stringify(ab), function(err) {
|
||||
if (err) return cb('Error deleting entry');
|
||||
root.list(function(err, ab) {
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@
|
|||
<i class="icon bp-arrow-right"></i>
|
||||
</div>
|
||||
<div class="item item-divider"></div>
|
||||
<div class="item has-click" ng-click="remove(addressbookEntry.address)">
|
||||
<div class="item has-click" ng-click="remove(addressbookEntry)">
|
||||
<span class="assertive" translate>Remove</span>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue