From 10b3f25a979eba707715efc13a651e20fd91585d Mon Sep 17 00:00:00 2001 From: Naomi Plasterer Date: Wed, 24 Apr 2024 13:44:30 -0700 Subject: [PATCH] fix: make the can message function return a map of addresses --- android/build.gradle | 2 +- .../java/expo/modules/xmtpreactnativesdk/XMTPModule.kt | 10 ++++++---- src/index.ts | 2 +- src/lib/Client.ts | 6 ++++-- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/android/build.gradle b/android/build.gradle index 6dfab186e..bb315920b 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -98,7 +98,7 @@ repositories { dependencies { implementation project(':expo-modules-core') implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${getKotlinVersion()}" - implementation "org.xmtp:android:0.10.5" + implementation "org.xmtp:android:0.10.6" implementation 'com.google.code.gson:gson:2.10.1' implementation 'com.facebook.react:react-native:0.71.3' implementation "com.daveanthonythomas.moshipack:moshipack:1.0.1" diff --git a/android/src/main/java/expo/modules/xmtpreactnativesdk/XMTPModule.kt b/android/src/main/java/expo/modules/xmtpreactnativesdk/XMTPModule.kt index 25bafdb6d..347ce28af 100644 --- a/android/src/main/java/expo/modules/xmtpreactnativesdk/XMTPModule.kt +++ b/android/src/main/java/expo/modules/xmtpreactnativesdk/XMTPModule.kt @@ -374,10 +374,12 @@ class XMTPModule : Module() { client.canMessage(peerAddress) } - AsyncFunction("canGroupMessage") { clientAddress: String, peerAddresses: List -> - logV("canGroupMessage") - val client = clients[clientAddress] ?: throw XMTPException("No client") - client.canMessageV3(peerAddresses) + AsyncFunction("canGroupMessage") Coroutine { clientAddress: String, peerAddresses: List -> + withContext(Dispatchers.IO) { + logV("canGroupMessage") + val client = clients[clientAddress] ?: throw XMTPException("No client") + client.canMessageV3(peerAddresses) + } } AsyncFunction("staticCanMessage") { peerAddress: String, environment: String, appVersion: String? -> diff --git a/src/index.ts b/src/index.ts index f2af4656e..ad722b918 100644 --- a/src/index.ts +++ b/src/index.ts @@ -288,7 +288,7 @@ export async function canMessage( export async function canGroupMessage( clientAddress: string, peerAddresses: string[] -): Promise { +): Promise<{ [key: string]: boolean }> { return await XMTPModule.canGroupMessage(clientAddress, peerAddresses) } diff --git a/src/lib/Client.ts b/src/lib/Client.ts index 714c4886c..16d4b1453 100644 --- a/src/lib/Client.ts +++ b/src/lib/Client.ts @@ -210,9 +210,11 @@ export class Client< * This method checks if the specified peers are using clients that support group messaging. * * @param {string[]} addresses - The addresses of the peers to check for messaging eligibility. - * @returns {Promise} A Promise resolving to true for peers where group messaging is allowed, and false otherwise. + * @returns {Promise<{ [key: string]: boolean }>} A Promise resolving to a hash of addresses and booleans if they can message on the V3 network. */ - async canGroupMessage(addresses: string[]): Promise { + async canGroupMessage( + addresses: string[] + ): Promise<{ [key: string]: boolean }> { return await XMTPModule.canGroupMessage(this.address, addresses) }