diff --git a/android/build.gradle b/android/build.gradle index 9ea79223c..bd15b1aa7 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:3.0.0" + implementation "org.xmtp:android:3.0.1" 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 1f4d010e5..8fc75330b 100644 --- a/android/src/main/java/expo/modules/xmtpreactnativesdk/XMTPModule.kt +++ b/android/src/main/java/expo/modules/xmtpreactnativesdk/XMTPModule.kt @@ -35,10 +35,13 @@ import kotlinx.coroutines.suspendCancellableCoroutine import kotlinx.coroutines.withContext import org.xmtp.android.library.Client import org.xmtp.android.library.ClientOptions +import org.xmtp.android.library.ConsentListEntry import org.xmtp.android.library.ConsentState import org.xmtp.android.library.Conversation -import org.xmtp.android.library.Conversations.ConversationOrder +import org.xmtp.android.library.Conversations +import org.xmtp.android.library.Conversations.* import org.xmtp.android.library.Dm +import org.xmtp.android.library.EntryType import org.xmtp.android.library.Group import org.xmtp.android.library.PreEventCallback import org.xmtp.android.library.SendOptions @@ -1099,10 +1102,18 @@ class XMTPModule : Module() { } } - AsyncFunction("setConsentState") Coroutine { inboxId: String -> + AsyncFunction("setConsentState") Coroutine { inboxId: String, value: String, entryType: String, consentType: String -> withContext(Dispatchers.IO) { val client = clients[inboxId] ?: throw XMTPException("No client") - val consentList = client.preferences.consentList.setConsentState() + val consentList = client.preferences.consentList.setConsentState( + listOf( + ConsentListEntry( + value, + getEntryType(entryType), + getConsentState(consentType) + ) + ) + ) } } @@ -1228,9 +1239,9 @@ class XMTPModule : Module() { private fun getStreamType(typeString: String): ConversationType { return when (typeString) { - "groups" -> GROUPS - "dms" -> DMS - else -> ALL + "groups" -> ConversationType.GROUPS + "dms" -> ConversationType.DMS + else -> ConversationType.ALL } } @@ -1242,6 +1253,15 @@ class XMTPModule : Module() { } } + private fun getEntryType(entryString: String): EntryType { + return when (entryString) { + "address" -> EntryType.ADDRESS + "conversation_id" -> EntryType.CONVERSATION_ID + "inbox_id" -> EntryType.INBOX_ID + else -> throw XMTPException("Invalid entry type: $entryString") + } + } + private fun getConversationSortOrder(order: String): ConversationOrder { return when (order) { "lastMessage" -> ConversationOrder.LAST_MESSAGE