From 9471bd18b21e54fcd6504c549703766eb4602aba Mon Sep 17 00:00:00 2001 From: Naomi Plasterer Date: Wed, 13 Nov 2024 10:16:13 -0800 Subject: [PATCH] implement it on android --- .../modules/xmtpreactnativesdk/XMTPModule.kt | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/android/src/main/java/expo/modules/xmtpreactnativesdk/XMTPModule.kt b/android/src/main/java/expo/modules/xmtpreactnativesdk/XMTPModule.kt index b7479673d..35ed22f0f 100644 --- a/android/src/main/java/expo/modules/xmtpreactnativesdk/XMTPModule.kt +++ b/android/src/main/java/expo/modules/xmtpreactnativesdk/XMTPModule.kt @@ -274,6 +274,14 @@ class XMTPModule : Module() { } } + AsyncFunction("getInboxStates") Coroutine { inboxId: String, refreshFromNetwork: Boolean, inboxIds: List -> + withContext(Dispatchers.IO) { + val client = clients[inboxId] ?: throw XMTPException("No client") + val inboxStates = client.inboxStatesForInboxIds(refreshFromNetwork, inboxIds) + inboxStates.map { InboxStateWrapper.encode(it) } + } + } + Function("preAuthenticateToInboxCallbackCompleted") { logV("preAuthenticateToInboxCallbackCompleted") preAuthenticateToInboxCallbackDeferred?.complete(Unit) @@ -531,11 +539,22 @@ class XMTPModule : Module() { } } + AsyncFunction("findDmByInboxId") Coroutine { inboxId: String, peerInboxId: String -> + withContext(Dispatchers.IO) { + logV("findDmByInboxId") + val client = clients[inboxId] ?: throw XMTPException("No client") + val dm = client.findDmByInboxId(peerInboxId) + dm?.let { + DmWrapper.encode(client, dm) + } + } + } + AsyncFunction("findDmByAddress") Coroutine { inboxId: String, peerAddress: String -> withContext(Dispatchers.IO) { logV("findDmByAddress") val client = clients[inboxId] ?: throw XMTPException("No client") - val dm = client.findDm(peerAddress) + val dm = client.findDmByAddress(peerAddress) dm?.let { DmWrapper.encode(client, dm) }