Skip to content

Commit

Permalink
add more awaits
Browse files Browse the repository at this point in the history
  • Loading branch information
nplasterer committed Sep 26, 2024
1 parent 2e28e90 commit b64e6e8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions ios/Wrappers/ConversationContainerWrapper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@ import XMTP

// Wrapper around XMTP.ConversationContainer to allow passing these objects back into react native.
struct ConversationContainerWrapper {
static func encodeToObj(_ conversation: XMTP.Conversation, client: XMTP.Client) throws -> [String: Any] {
static func encodeToObj(_ conversation: XMTP.Conversation, client: XMTP.Client) async throws -> [String: Any] {
switch conversation {
case .group(let group):
return try GroupWrapper.encodeToObj(group, client: client)
return try await GroupWrapper.encodeToObj(group, client: client)
default:
return try ConversationWrapper.encodeToObj(conversation, client: client)
}
}

static func encode(_ conversation: XMTP.Conversation, client: XMTP.Client) throws -> String {
let obj = try encodeToObj(conversation, client: client)
static func encode(_ conversation: XMTP.Conversation, client: XMTP.Client) async throws -> String {
let obj = try await encodeToObj(conversation, client: client)
let data = try JSONSerialization.data(withJSONObject: obj)
guard let result = String(data: data, encoding: .utf8) else {
throw WrapperError.encodeError("could not encode conversation")
Expand Down
4 changes: 2 additions & 2 deletions ios/XMTPModule.swift
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,7 @@ public class XMTPModule: Module {
var results: [String] = []
for conversation in conversationContainerList {
await self.conversationsManager.set(conversation.cacheKey(inboxId), conversation)
let encodedConversationContainer = try ConversationContainerWrapper.encode(conversation, client: client)
let encodedConversationContainer = try await ConversationContainerWrapper.encode(conversation, client: client)
results.append(encodedConversationContainer)
}

Expand Down Expand Up @@ -1832,7 +1832,7 @@ public class XMTPModule: Module {
await subscriptionsManager.set(getConversationsKey(inboxId: inboxId), Task {
do {
for try await conversation in await client.conversations.streamAll() {
try sendEvent("conversationContainer", [
try await sendEvent("conversationContainer", [
"inboxId": inboxId,
"conversationContainer": ConversationContainerWrapper.encodeToObj(conversation, client: client),
])
Expand Down

0 comments on commit b64e6e8

Please sign in to comment.