|
|
@ -14,8 +14,8 @@ class AddressBookController { |
|
|
|
// PUBLIC METHODS
|
|
|
|
// PUBLIC METHODS
|
|
|
|
//
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
|
|
setAddressList (address, name) { |
|
|
|
setAddressBook (address, name) { |
|
|
|
return this.addToAddressList(address, name) |
|
|
|
return this.addToAddressBook(address, name) |
|
|
|
.then((addressBook) => { |
|
|
|
.then((addressBook) => { |
|
|
|
this.store.updateState({ |
|
|
|
this.store.updateState({ |
|
|
|
addressBook, |
|
|
|
addressBook, |
|
|
@ -24,9 +24,9 @@ class AddressBookController { |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
addToAddressList (address, name) { |
|
|
|
addToAddressBook (address, name) { |
|
|
|
let addressBook = this.getAddressList() |
|
|
|
let addressBook = this.getAddressBook() |
|
|
|
let index = addressBook.findIndex((element) => { return element.address === address }) |
|
|
|
let index = addressBook.findIndex((element) => { return element.address === address || element.name === name }) |
|
|
|
if (index !== -1) { |
|
|
|
if (index !== -1) { |
|
|
|
addressBook.splice(index, 1) |
|
|
|
addressBook.splice(index, 1) |
|
|
|
} |
|
|
|
} |
|
|
@ -37,7 +37,7 @@ class AddressBookController { |
|
|
|
return Promise.resolve(addressBook) |
|
|
|
return Promise.resolve(addressBook) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
getAddressList () { |
|
|
|
getAddressBook () { |
|
|
|
return this.store.getState().addressBook |
|
|
|
return this.store.getState().addressBook |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|