Skip to content

Commit

Permalink
add back limit
Browse files Browse the repository at this point in the history
  • Loading branch information
nplasterer committed Oct 24, 2024
1 parent 93bd230 commit bf43701
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,7 @@ class XMTPModule : Module() {
val sortedGroupList = if (order == ConversationOrder.LAST_MESSAGE) {
client.conversations.listGroups()
.sortedByDescending { group ->
group.decryptedMessages().firstOrNull()?.sentAt
group.decryptedMessages(limit = 1).firstOrNull()?.sentAt
}
.let { groups ->
if (limit != null && limit > 0) groups.take(limit) else groups
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class GroupWrapper {
put("consentState", consentStateToString(group.consentState()))
}
if (groupParams.lastMessage) {
val lastMessage = group.decryptedMessages().firstOrNull()
val lastMessage = group.decryptedMessages(limit = 1).firstOrNull()
if (lastMessage != null) {
put("lastMessage", DecodedMessageWrapper.encode(lastMessage))
}
Expand Down
2 changes: 1 addition & 1 deletion ios/Wrappers/GroupWrapper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ struct GroupWrapper {
result["consentState"] = ConsentWrapper.consentStateToString(state: try group.consentState())
}
if groupParams.lastMessage {
if let lastMessage = try await group.decryptedMessages().first {
if let lastMessage = try await group.decryptedMessages(limit: 1).first {
result["lastMessage"] = try DecodedMessageWrapper.encode(lastMessage, client: client)
}
}
Expand Down
2 changes: 1 addition & 1 deletion ios/XMTPModule.swift
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@ public class XMTPModule: Module {
var groupsWithMessages: [(Group, Date)] = []
for group in groups {
do {
let firstMessage = try await group.decryptedMessages().first
let firstMessage = try await group.decryptedMessages(limit: 1).first
let sentAt = firstMessage?.sentAt ?? Date.distantPast
groupsWithMessages.append((group, sentAt))
} catch {
Expand Down

0 comments on commit bf43701

Please sign in to comment.