Skip to content

Commit d42be02

Browse files
authored
Merge pull request #47 from xmtp/daniel-actual-batch-ios
feat: (iOS) use batchQuery instead of one-at-a-time for messages
2 parents 27c5b16 + ffb330d commit d42be02

File tree

2 files changed

+7
-14
lines changed

2 files changed

+7
-14
lines changed

ios/XMTPModule.swift

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -160,23 +160,16 @@ public class XMTPModule: Module {
160160
let beforeDate = before != nil ? Date(timeIntervalSince1970: before!) : nil
161161
let afterDate = after != nil ? Date(timeIntervalSince1970: after!) : nil
162162
var messages:[String] = []
163-
// TODO: use batchQuery instead of one-at-a-time (once iOS and libxmtp support it).
164-
for (topic, conversationID) in zip(topics, conversationIDs) {
165-
guard let conversation = try await findConversation(
166-
clientAddress: clientAddress,
167-
topic: topic,
168-
conversationID: conversationID) else {
169-
throw Error.conversationNotFound("no conversation found for \(topic)")
170-
}
171-
messages += try await conversation.messages(
163+
guard let client = clients[clientAddress] else {
164+
throw Error.noClient
165+
}
166+
return try await client.conversations.listBatchMessages(
167+
topics: topics,
172168
limit: limit,
173169
before: beforeDate,
174170
after: afterDate)
175171
.map { (msg) in try DecodedMessageWrapper.encode(msg) }
176172
}
177-
// print("found \(messages.count) messages from \(topics.count) conversations");
178-
return messages
179-
}
180173

181174
// TODO: Support content types
182175
AsyncFunction("sendMessage") { (clientAddress: String, conversationTopic: String, conversationID: String?, content: String) -> String in

ios/XMTPReactNative.podspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Pod::Spec.new do |s|
2222
'DEFINES_MODULE' => 'YES',
2323
'SWIFT_COMPILATION_MODE' => 'wholemodule'
2424
}
25-
25+
2626
s.source_files = "**/*.{h,m,swift}"
27-
s.dependency "XMTP", "= 0.2.2-alpha0"
27+
s.dependency "XMTP", "= 0.3.0-alpha0"
2828
end

0 commit comments

Comments
 (0)