Skip to content

Commit

Permalink
get the threading issue working
Browse files Browse the repository at this point in the history
  • Loading branch information
nplasterer committed Sep 20, 2023
1 parent c20814a commit 30aa0b8
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions ios/XMTPModule.swift
Original file line number Diff line number Diff line change
Expand Up @@ -276,11 +276,21 @@ public class XMTPModule: Module {
}

let conversations = try await client.conversations.list()

return try conversations.map { conversation in
await conversationsManager.updateConversation(key: conversation.cacheKey(clientAddress), conversation: conversation)

return try ConversationWrapper.encode(conversation, client: client)

return try await withThrowingTaskGroup(of: String.self) { group in
for conversation in conversations {
group.addTask {
await self.conversationsManager.updateConversation(key: conversation.cacheKey(clientAddress), conversation: conversation)
return try await ConversationWrapper.encode(conversation, client: client)
}
}

var results: [String] = []
for try await result in group {
results.append(result)
}

return results
}
}

Expand Down

0 comments on commit 30aa0b8

Please sign in to comment.