Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: (iOS) use batchQuery instead of one-at-a-time for messages #47

Merged
merged 1 commit into from
Jun 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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