Merge pull request #87 from Bitcoin-com/dev-jb

Dev jb
This commit is contained in:
Jean-Baptiste Dominguez 2018-04-30 16:52:21 +09:00 committed by GitHub
commit 38f172f6fb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 25 additions and 9 deletions

View file

@ -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;

View file

@ -15,7 +15,10 @@ angular.module('copayApp.directives')
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;
}

View file

@ -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) {

View file

@ -6,7 +6,7 @@
<span>{{addressbookEntry.name}}</span>
</ion-nav-title>
</ion-nav-bar>
<ion-content scroll="false">
<ion-content>
<div class="gravatar-content">
<i class="icon big-icon-svg" ng-if="isChromeApp">
<img src="img/contact-placeholder.svg" class="bg"/>
@ -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>