commit
38f172f6fb
4 changed files with 25 additions and 9 deletions
|
|
@ -40,12 +40,13 @@ angular.module('copayApp.controllers').controller('addressbookViewController', f
|
||||||
}, 100);
|
}, 100);
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.remove = function(addr) {
|
$scope.remove = function(addressbookEntry) {
|
||||||
var title = gettextCatalog.getString('Warning!');
|
var title = gettextCatalog.getString('Warning!');
|
||||||
var message = gettextCatalog.getString('Are you sure you want to delete this contact?');
|
var message = gettextCatalog.getString('Are you sure you want to delete this contact?');
|
||||||
popupService.showConfirm(title, message, null, null, function(res) {
|
popupService.showConfirm(title, message, null, null, function(res) {
|
||||||
if (!res) return;
|
if (!res) return;
|
||||||
addressbookService.remove(addr, function(err, ab) {
|
|
||||||
|
addressbookService.remove(addressbookEntry, function(err, ab) {
|
||||||
if (err) {
|
if (err) {
|
||||||
popupService.showAlert(gettextCatalog.getString('Error'), err);
|
popupService.showAlert(gettextCatalog.getString('Error'), err);
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,10 @@ angular.module('copayApp.directives')
|
||||||
|
|
||||||
var validator = function(value) {
|
var validator = function(value) {
|
||||||
|
|
||||||
if (value.indexOf('bitcoincash:') >= 0 || value[0] == 'C' || value[0] == 'H') {
|
if (value.indexOf('bitcoincash:') >= 0 || value[0] == 'C' || value[0] == 'H' || value[0] == 'p' || value[0] == 'q') {
|
||||||
|
if (value.indexOf('bitcoincash:') < 0) {
|
||||||
|
value = 'bitcoincash:' + value;
|
||||||
|
}
|
||||||
value = bitcoinCashJsService.readAddress(value).legacy;
|
value = bitcoinCashJsService.readAddress(value).legacy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -64,16 +64,28 @@ angular.module('copayApp.services').factory('addressbookService', function($log,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
root.remove = function(addr, cb) {
|
root.remove = function(entry, cb) {
|
||||||
var network = getNetwork(addr);
|
|
||||||
|
// 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');
|
if (lodash.isEmpty(network)) return cb('Not valid bitcoin address');
|
||||||
storageService.getAddressbook(network, function(err, ab) {
|
storageService.getAddressbook(network, function(err, ab) {
|
||||||
if (err) return cb(err);
|
if (err) return cb(err);
|
||||||
if (ab) ab = JSON.parse(ab);
|
if (ab) ab = JSON.parse(ab);
|
||||||
ab = ab || {};
|
ab = ab || {};
|
||||||
if (lodash.isEmpty(ab)) return cb('Addressbook is empty');
|
if (lodash.isEmpty(ab)) return cb('Addressbook is empty');
|
||||||
if (!ab[addr]) return cb('Entry does not exist');
|
if (!ab[entry.coin + entry.address]) return cb('Entry does not exist');
|
||||||
delete ab[addr];
|
delete ab[entry.coin + entry.address];
|
||||||
storageService.setAddressbook(network, JSON.stringify(ab), function(err) {
|
storageService.setAddressbook(network, JSON.stringify(ab), function(err) {
|
||||||
if (err) return cb('Error deleting entry');
|
if (err) return cb('Error deleting entry');
|
||||||
root.list(function(err, ab) {
|
root.list(function(err, ab) {
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
<span>{{addressbookEntry.name}}</span>
|
<span>{{addressbookEntry.name}}</span>
|
||||||
</ion-nav-title>
|
</ion-nav-title>
|
||||||
</ion-nav-bar>
|
</ion-nav-bar>
|
||||||
<ion-content scroll="false">
|
<ion-content>
|
||||||
<div class="gravatar-content">
|
<div class="gravatar-content">
|
||||||
<i class="icon big-icon-svg" ng-if="isChromeApp">
|
<i class="icon big-icon-svg" ng-if="isChromeApp">
|
||||||
<img src="img/contact-placeholder.svg" class="bg"/>
|
<img src="img/contact-placeholder.svg" class="bg"/>
|
||||||
|
|
@ -36,7 +36,7 @@
|
||||||
<i class="icon bp-arrow-right"></i>
|
<i class="icon bp-arrow-right"></i>
|
||||||
</div>
|
</div>
|
||||||
<div class="item item-divider"></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>
|
<span class="assertive" translate>Remove</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue