Allow receiving and sending messages before lokiP2PApi is defined.

pull/438/head
sachaaaaa 6 years ago
parent 5eab2098b6
commit 4dd62a265c

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

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

Loading…
Cancel
Save