Skip to content

Commit

Permalink
get android dialed
Browse files Browse the repository at this point in the history
  • Loading branch information
nplasterer committed Nov 9, 2024
1 parent 942d79b commit 323e249
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 7 deletions.
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
)
)
)
}
}

Expand Down Expand Up @@ -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
}
}

Expand 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
Expand Down

0 comments on commit 323e249

Please sign in to comment.