From 603a4e8a43c7a1eaa37d1f6601b0bc6a56a4ceca Mon Sep 17 00:00:00 2001 From: Naomi Plasterer Date: Fri, 8 Nov 2024 13:05:46 -0800 Subject: [PATCH 1/3] update to take API instead of client options --- library/src/main/java/org/xmtp/android/library/Client.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/library/src/main/java/org/xmtp/android/library/Client.kt b/library/src/main/java/org/xmtp/android/library/Client.kt index 749126042..122b97df0 100644 --- a/library/src/main/java/org/xmtp/android/library/Client.kt +++ b/library/src/main/java/org/xmtp/android/library/Client.kt @@ -58,11 +58,11 @@ class Client() { registry } - suspend fun getOrCreateInboxId(options: ClientOptions, address: String): String { + suspend fun getOrCreateInboxId(environment: ClientOptions.Api, address: String): String { var inboxId = getInboxIdForAddress( logger = XMTPLogger(), - host = options.api.env.getUrl(), - isSecure = options.api.isSecure, + host = environment.env.getUrl(), + isSecure = environment.isSecure, accountAddress = address ) if (inboxId.isNullOrBlank()) { From 8709bccb67fb6c2f15815e70d2f22a17bb144a9d Mon Sep 17 00:00:00 2001 From: Naomi Plasterer Date: Fri, 8 Nov 2024 14:12:02 -0800 Subject: [PATCH 2/3] update android bridge to be v3 only --- library/src/main/java/org/xmtp/android/library/Client.kt | 2 +- .../src/main/java/org/xmtp/android/library/Conversation.kt | 7 +++++++ .../java/org/xmtp/android/library/PrivatePreferences.kt | 1 + 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/library/src/main/java/org/xmtp/android/library/Client.kt b/library/src/main/java/org/xmtp/android/library/Client.kt index 122b97df0..dd4e16ad0 100644 --- a/library/src/main/java/org/xmtp/android/library/Client.kt +++ b/library/src/main/java/org/xmtp/android/library/Client.kt @@ -101,7 +101,7 @@ class Client() { signingKey: SigningKey? = null, ): Client { val accountAddress = address.lowercase() - val inboxId = getOrCreateInboxId(clientOptions, accountAddress) + val inboxId = getOrCreateInboxId(clientOptions.api, accountAddress) val (ffiClient, dbPath) = createFfiClient( accountAddress, diff --git a/library/src/main/java/org/xmtp/android/library/Conversation.kt b/library/src/main/java/org/xmtp/android/library/Conversation.kt index 8177e858e..dc6310667 100644 --- a/library/src/main/java/org/xmtp/android/library/Conversation.kt +++ b/library/src/main/java/org/xmtp/android/library/Conversation.kt @@ -112,6 +112,13 @@ sealed class Conversation { } } + suspend fun publishMessages() { + return when (this) { + is Group -> group.publishMessages() + is Dm -> dm.publishMessages() + } + } + val client: Client get() { return when (this) { diff --git a/library/src/main/java/org/xmtp/android/library/PrivatePreferences.kt b/library/src/main/java/org/xmtp/android/library/PrivatePreferences.kt index e345327de..267ca4945 100644 --- a/library/src/main/java/org/xmtp/android/library/PrivatePreferences.kt +++ b/library/src/main/java/org/xmtp/android/library/PrivatePreferences.kt @@ -88,6 +88,7 @@ data class ConsentListEntry( class ConsentList( val client: Client, private val ffiClient: FfiXmtpClient, + val entries: MutableMap = mutableMapOf(), ) { suspend fun setConsentState(entries: List) { ffiClient.setConsentStates(entries.map { it.toFfiConsent() }) From c3bd4d16775d94e7ce7d9c76d13a19e1a3bc8be1 Mon Sep 17 00:00:00 2001 From: Naomi Plasterer Date: Fri, 8 Nov 2024 14:20:28 -0800 Subject: [PATCH 3/3] fix up the tests --- .../androidTest/java/org/xmtp/android/library/ClientTest.kt | 2 +- .../java/org/xmtp/android/library/ConversationsTest.kt | 5 ++--- .../main/java/org/xmtp/android/library/PrivatePreferences.kt | 1 - 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/library/src/androidTest/java/org/xmtp/android/library/ClientTest.kt b/library/src/androidTest/java/org/xmtp/android/library/ClientTest.kt index 55889e5a3..59bcb4956 100644 --- a/library/src/androidTest/java/org/xmtp/android/library/ClientTest.kt +++ b/library/src/androidTest/java/org/xmtp/android/library/ClientTest.kt @@ -55,7 +55,7 @@ class ClientTest { appContext = context, dbEncryptionKey = key ) - val inboxId = runBlocking { Client.getOrCreateInboxId(options, fakeWallet.address) } + val inboxId = runBlocking { Client.getOrCreateInboxId(options.api, fakeWallet.address) } val client = runBlocking { Client().create( account = fakeWallet, diff --git a/library/src/androidTest/java/org/xmtp/android/library/ConversationsTest.kt b/library/src/androidTest/java/org/xmtp/android/library/ConversationsTest.kt index 5dda00093..3445effef 100644 --- a/library/src/androidTest/java/org/xmtp/android/library/ConversationsTest.kt +++ b/library/src/androidTest/java/org/xmtp/android/library/ConversationsTest.kt @@ -190,8 +190,6 @@ class ConversationsTest { boClient.conversations.sync() } val boDm = runBlocking { boClient.findConversation(dm.id) } - alixClient.dropLocalDatabaseConnection() - alixClient.deleteLocalDatabase() val alixClient2 = runBlocking { Client().create( @@ -199,7 +197,8 @@ class ConversationsTest { options = ClientOptions( ClientOptions.Api(XMTPEnvironment.LOCAL, false), appContext = context, - dbEncryptionKey = key + dbEncryptionKey = key, + dbDirectory = context.filesDir.absolutePath.toString() ) ) } diff --git a/library/src/main/java/org/xmtp/android/library/PrivatePreferences.kt b/library/src/main/java/org/xmtp/android/library/PrivatePreferences.kt index 267ca4945..e345327de 100644 --- a/library/src/main/java/org/xmtp/android/library/PrivatePreferences.kt +++ b/library/src/main/java/org/xmtp/android/library/PrivatePreferences.kt @@ -88,7 +88,6 @@ data class ConsentListEntry( class ConsentList( val client: Client, private val ffiClient: FfiXmtpClient, - val entries: MutableMap = mutableMapOf(), ) { suspend fun setConsentState(entries: List) { ffiClient.setConsentStates(entries.map { it.toFfiConsent() })