From cde7bbf3c3a6beb25c0d81dbde168af985a40de2 Mon Sep 17 00:00:00 2001 From: Beaudan Date: Wed, 6 Feb 2019 11:49:46 +1100 Subject: [PATCH] Removed forceP2p as argument for the pingContact event and enforced it on the other side --- js/background.js | 8 ++++---- js/modules/loki_p2p_api.js | 2 +- libloki/test/node/loki_p2p_api_test.js | 3 +-- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/js/background.js b/js/background.js index b25fc5d41..f37fc6fd7 100644 --- a/js/background.js +++ b/js/background.js @@ -222,10 +222,10 @@ window.lokiP2pAPI = new window.LokiP2pAPI( textsecure.storage.user.getNumber() ); - window.lokiP2pAPI.on( - 'pingContact', - window.libloki.api.sendOnlineBroadcastMessage - ); + window.lokiP2pAPI.on('pingContact', pubKey => { + const forceP2p = true; + window.libloki.api.sendOnlineBroadcastMessage(pubKey, forceP2p); + }); // These make key operations available to IPC handlers created in preload.js window.Events = { diff --git a/js/modules/loki_p2p_api.js b/js/modules/loki_p2p_api.js index f8d9563d9..349517c6b 100644 --- a/js/modules/loki_p2p_api.js +++ b/js/modules/loki_p2p_api.js @@ -80,7 +80,7 @@ class LokiP2pAPI extends EventEmitter { if (!this.contactP2pDetails[pubKey]) { return; } - this.emit('pingContact', pubKey, true); + this.emit('pingContact', pubKey); } } diff --git a/libloki/test/node/loki_p2p_api_test.js b/libloki/test/node/loki_p2p_api_test.js index 1c4d261ce..9448be27c 100644 --- a/libloki/test/node/loki_p2p_api_test.js +++ b/libloki/test/node/loki_p2p_api_test.js @@ -44,8 +44,7 @@ describe('LocalLokiServer', () => { const timer = setTimeout(() => { promise = Promise.resolve(); }, 5000); - this.lokiP2pAPI.on('pingContact', (pubKey, forceP2p) => { - assert.isTrue(forceP2p); + this.lokiP2pAPI.on('pingContact', pubKey => { clearTimeout(timer); promise = Promise.resolve(pubKey); });