From 4dd62a265cb7f3739b23759e415d2d8a5c4c470f Mon Sep 17 00:00:00 2001 From: sachaaaaa Date: Tue, 27 Aug 2019 13:50:39 +1000 Subject: [PATCH] Allow receiving and sending messages before lokiP2PApi is defined. --- js/models/conversations.js | 2 +- js/modules/loki_message_api.js | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/js/models/conversations.js b/js/models/conversations.js index 891a345d5..15d265021 100644 --- a/js/models/conversations.js +++ b/js/models/conversations.js @@ -167,7 +167,7 @@ if (this.id === this.ourNumber) { this.set({ friendRequestStatus: FriendRequestStatusEnum.friends }); - } else if (lokiP2pAPI) { + } else if (typeof lokiP2pAPI !== 'undefined') { // Online status handling, only for contacts that aren't us this.set({ isOnline: lokiP2pAPI.isOnline(this.id) }); } else { diff --git a/js/modules/loki_message_api.js b/js/modules/loki_message_api.js index 199448a57..22fde099e 100644 --- a/js/modules/loki_message_api.js +++ b/js/modules/loki_message_api.js @@ -39,6 +39,9 @@ const calcNonce = (messageEventData, pubKey, data64, timestamp, ttl) => { }; const trySendP2p = async (pubKey, data64, isPing, messageEventData) => { + if (typeof lokiP2pAPI === 'undefined') { + return false; + } const p2pDetails = lokiP2pAPI.getContactP2pDetails(pubKey); if (!p2pDetails || (!isPing && !p2pDetails.isOnline)) { return false;