Merge pull request #438 from sachaaaaa/allow_messages_without_lokip2p

[multi-device] Allow receiving and sending messages before lokiP2PApi is defined.
pull/454/head
sachaaaaa 6 years ago committed by GitHub
commit 1c447c0589
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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