diff --git a/android/src/main/java/expo/modules/xmtpreactnativesdk/XMTPModule.kt b/android/src/main/java/expo/modules/xmtpreactnativesdk/XMTPModule.kt index 151590484..46f8be27e 100644 --- a/android/src/main/java/expo/modules/xmtpreactnativesdk/XMTPModule.kt +++ b/android/src/main/java/expo/modules/xmtpreactnativesdk/XMTPModule.kt @@ -278,6 +278,9 @@ class XMTPModule : Module() { val data = TopicData.parseFrom(Base64.decode(topicData, NO_WRAP)) val conversation = client.conversations.importTopicData(data) conversations[conversation.cacheKey(clientAddress)] = conversation + if (conversation.keyMaterial == null) { + logV("Null key material before encode conversation") + } ConversationWrapper.encode(client, conversation) } @@ -381,6 +384,9 @@ class XMTPModule : Module() { val conversationList = client.conversations.list() conversationList.map { conversation -> conversations[conversation.cacheKey(clientAddress)] = conversation + if (conversation.keyMaterial == null) { + logV("Null key material before encode conversation") + } ConversationWrapper.encode(client, conversation) } } @@ -561,6 +567,9 @@ class XMTPModule : Module() { }, ) ) + if (conversation.keyMaterial == null) { + logV("Null key material before encode conversation") + } ConversationWrapper.encode(client, conversation) } @@ -713,13 +722,21 @@ class XMTPModule : Module() { subscriptions[getConversationsKey(clientAddress)] = CoroutineScope(Dispatchers.IO).launch { try { client.conversations.stream().collect { conversation -> - sendEvent( - "conversation", - mapOf( - "clientAddress" to clientAddress, - "conversation" to ConversationWrapper.encodeToObj(client, conversation) + run { + if (conversation.keyMaterial == null) { + logV("Null key material before encode conversation") + } + sendEvent( + "conversation", + mapOf( + "clientAddress" to clientAddress, + "conversation" to ConversationWrapper.encodeToObj( + client, + conversation + ) + ) ) - ) + } } } catch (e: Exception) { Log.e("XMTPModule", "Error in conversations subscription: $e") diff --git a/android/src/main/java/expo/modules/xmtpreactnativesdk/wrappers/ConversationWrapper.kt b/android/src/main/java/expo/modules/xmtpreactnativesdk/wrappers/ConversationWrapper.kt index 97d88beed..6d31ccb8f 100644 --- a/android/src/main/java/expo/modules/xmtpreactnativesdk/wrappers/ConversationWrapper.kt +++ b/android/src/main/java/expo/modules/xmtpreactnativesdk/wrappers/ConversationWrapper.kt @@ -26,7 +26,7 @@ class ConversationWrapper { "peerAddress" to conversation.peerAddress, "version" to if (conversation.version == Conversation.Version.V1) "v1" else "v2", "conversationID" to (conversation.conversationId ?: ""), - "keyMaterial" to Base64.encodeToString(conversation.keyMaterial, Base64.NO_WRAP) + "keyMaterial" to (conversation.keyMaterial?.let { Base64.encodeToString(it, Base64.NO_WRAP) } ?: "") ) }