-
Notifications
You must be signed in to change notification settings - Fork 29
Add insertedAt field and sortBy options #753
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
base: main
Are you sure you want to change the base?
Conversation
|
Add
|
b7ab021 to
a49d162
Compare
| decoded.contentTypeId, | ||
| decoded.senderInboxId, | ||
| decoded.sentNs, | ||
| decoded.insertedAtNs, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
from doesn’t default insertedAtNs. If it’s missing in JSON, this.insertedAtNs becomes undefined, unlike fromObject. Consider defaulting to decoded.sentNs here to keep it a number.
| decoded.insertedAtNs, | |
| decoded.insertedAtNs ?? decoded.sentNs, |
🚀 Reply to ask Macroscope to explain or update this suggestion.
👍 Helpful? React to give us feedback.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Issue on line in ios/XMTPModule.swift:388:
Casting chainId to UInt64 can trap for negatives. Suggest validating chainId >= 0 everywhere before casting and failing early with a clear error if invalid.
🚀 Reply to ask Macroscope to explain or update this suggestion.
👍 Helpful? React to give us feedback.
| try? encodeToObj(childMessage) | ||
| } | ||
| ] | ||
| "childMessages": model.childMessages?.map { childMessage in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"childMessages" may be an Optional and may contain nil entries due to try?, which breaks JSON encoding. Consider using compactMap to drop nils and defaulting to a concrete array (or omit the key / use NSNull() if no children). You might also consider propagating child encode errors instead of silently dropping them.
- "childMessages": model.childMessages?.map { childMessage in
- try? encodeToObj(childMessage)
- },
+ "childMessages": model.childMessages?.compactMap { try? encodeToObj($0) } ?? [],
🚀 Reply to ask Macroscope to explain or update this suggestion.
👍 Helpful? React to give us feedback.
a49d162 to
d7c5aeb
Compare
d7c5aeb to
1253152
Compare

TL;DR
Update XMTP SDK to support message sorting by insertion time and message counting functionality.
What changed?
org.xmtp:android:4.6.1-rc1→4.7.0-dev.252eebcXMTP: 4.6.1-rc3→4.7.0-dev.ff66c0finsertedAfterNsinsertedBeforeNssortBy(with optionsSENTorINSERTED)insertedAtNsfield to message objectscountMessagesfunction to get message counts without fetching full messagesHow to test?
insertedAtNsfield is available on message objects:Why make this change?
This change provides developers with more flexibility in how they query and display messages:
Sorting by insertion time allows for more accurate chronological display of messages as they were received by the client, rather than when they were sent.
The message counting functionality enables pagination and UI features that need to know the total count without fetching all messages, improving performance for conversations with many messages.
The
insertedAtNstimestamp provides additional metadata that can be useful for tracking when messages were actually received by the client versus when they were sent.