Skip to content

Commit

Permalink
fix the parsing issue
Browse files Browse the repository at this point in the history
  • Loading branch information
nplasterer committed Sep 26, 2024
1 parent 601bf7b commit 1ee838d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import org.xmtp.android.library.Conversation
class ConversationContainerWrapper {

companion object {
fun encodeToObj(client: Client, conversation: Conversation): Map<String, Any?> {
suspend fun encodeToObj(client: Client, conversation: Conversation): Map<String, Any?> {
when (conversation.version) {
Conversation.Version.GROUP -> {
val group = (conversation as Conversation.Group).group
Expand All @@ -20,7 +20,7 @@ class ConversationContainerWrapper {
}
}

fun encode(client: Client, conversation: Conversation): String {
suspend fun encode(client: Client, conversation: Conversation): String {
val gson = GsonBuilder().create()
val obj = ConversationContainerWrapper.encodeToObj(client, conversation)
return gson.toJson(obj)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,29 @@
package expo.modules.xmtpreactnativesdk.wrappers

import com.google.gson.Gson
import com.google.gson.GsonBuilder
import uniffi.xmtpv3.org.xmtp.android.library.libxmtp.InboxState

class InboxStateWrapper {
companion object {
val gson: Gson = GsonBuilder().create()
fun encodeToObj(inboxState: InboxState): Map<String, Any> {
return mapOf(
"inboxId" to inboxState.inboxId,
"addresses" to inboxState.addresses,
"installations" to inboxState.installations.map {
mapOf(
"id" to it.installationId,
"createdAt" to it.createdAt?.time
gson.toJson(
mapOf(
"id" to it.installationId,
"createdAt" to it.createdAt?.time
)
)
},
"recoveryAddress" to inboxState.recoveryAddress
)
}

fun encode(inboxState: InboxState): String {
val gson = GsonBuilder().create()
val obj = encodeToObj(inboxState)
return gson.toJson(obj)
}
Expand Down

0 comments on commit 1ee838d

Please sign in to comment.