Skip to content

Commit

Permalink
Merge pull request #47 from xmtp/daniel-actual-batch-ios
Browse files Browse the repository at this point in the history
feat: (iOS) use batchQuery instead of one-at-a-time for messages
  • Loading branch information
dmccartney authored Jun 5, 2023
2 parents 27c5b16 + ffb330d commit d42be02
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 14 deletions.
17 changes: 5 additions & 12 deletions ios/XMTPModule.swift
Original file line number Diff line number Diff line change
Expand Up @@ -160,23 +160,16 @@ public class XMTPModule: Module {
let beforeDate = before != nil ? Date(timeIntervalSince1970: before!) : nil
let afterDate = after != nil ? Date(timeIntervalSince1970: after!) : nil
var messages:[String] = []
// TODO: use batchQuery instead of one-at-a-time (once iOS and libxmtp support it).
for (topic, conversationID) in zip(topics, conversationIDs) {
guard let conversation = try await findConversation(
clientAddress: clientAddress,
topic: topic,
conversationID: conversationID) else {
throw Error.conversationNotFound("no conversation found for \(topic)")
}
messages += try await conversation.messages(
guard let client = clients[clientAddress] else {
throw Error.noClient
}
return try await client.conversations.listBatchMessages(
topics: topics,
limit: limit,
before: beforeDate,
after: afterDate)
.map { (msg) in try DecodedMessageWrapper.encode(msg) }
}
// print("found \(messages.count) messages from \(topics.count) conversations");
return messages
}

// TODO: Support content types
AsyncFunction("sendMessage") { (clientAddress: String, conversationTopic: String, conversationID: String?, content: String) -> String in
Expand Down
4 changes: 2 additions & 2 deletions ios/XMTPReactNative.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Pod::Spec.new do |s|
'DEFINES_MODULE' => 'YES',
'SWIFT_COMPILATION_MODE' => 'wholemodule'
}

s.source_files = "**/*.{h,m,swift}"
s.dependency "XMTP", "= 0.2.2-alpha0"
s.dependency "XMTP", "= 0.3.0-alpha0"
end

0 comments on commit d42be02

Please sign in to comment.