Skip to content

Commit

Permalink
Small tweaks to tests and classes (#321)
Browse files Browse the repository at this point in the history
* update to take API instead of client options

* update android bridge to be v3 only

* fix up the tests
  • Loading branch information
nplasterer authored Nov 8, 2024
1 parent 912714b commit d71c74f
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,16 +190,15 @@ class ConversationsTest {
boClient.conversations.sync()
}
val boDm = runBlocking { boClient.findConversation(dm.id) }
alixClient.dropLocalDatabaseConnection()
alixClient.deleteLocalDatabase()

val alixClient2 = runBlocking {
Client().create(
account = alixWallet,
options = ClientOptions(
ClientOptions.Api(XMTPEnvironment.LOCAL, false),
appContext = context,
dbEncryptionKey = key
dbEncryptionKey = key,
dbDirectory = context.filesDir.absolutePath.toString()
)
)
}
Expand Down
8 changes: 4 additions & 4 deletions library/src/main/java/org/xmtp/android/library/Client.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit d71c74f

Please sign in to comment.