diff --git a/index.html b/index.html
index 109db61..1f6c739 100644
--- a/index.html
+++ b/index.html
@@ -338,7 +338,7 @@
async resetPath(contact) {
// remove contact from device
- await this.connection.sendCommandResetPath(contact.publicKey);
+ await this.connection.resetPath(contact.publicKey);
// reload contacts
await this.loadContacts();
diff --git a/src/connection/connection.js b/src/connection/connection.js
index 3c9275c..0342037 100644
--- a/src/connection/connection.js
+++ b/src/connection/connection.js
@@ -819,6 +819,37 @@ class Connection extends EventEmitter {
});
}
+ resetPath(pubKey) {
+ return new Promise(async (resolve, reject) => {
+ try {
+
+ // resolve promise when we receive ok
+ const onOk = () => {
+ this.off(Constants.ResponseCodes.Ok, onOk);
+ this.off(Constants.ResponseCodes.Err, onErr);
+ resolve();
+ }
+
+ // reject promise when we receive err
+ const onErr = () => {
+ this.off(Constants.ResponseCodes.Ok, onOk);
+ this.off(Constants.ResponseCodes.Err, onErr);
+ reject();
+ }
+
+ // listen for events
+ this.once(Constants.ResponseCodes.Ok, onOk);
+ this.once(Constants.ResponseCodes.Err, onErr);
+
+ // reset path
+ await this.sendCommandResetPath(pubKey);
+
+ } catch(e) {
+ reject(e);
+ }
+ });
+ }
+
}
export default Connection;