-
Notifications
You must be signed in to change notification settings - Fork 46
chat docs: fix missing chat kotlin/swift/jetpack doc #3098
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: feature/chat-jetpack-compose-docs
Are you sure you want to change the base?
chat docs: fix missing chat kotlin/swift/jetpack doc #3098
Conversation
WalkthroughThis PR adds comprehensive multi-language code examples for media sharing, message replies, and message reactions across the chat documentation, while correcting a Swift API parameter label in the message history section from Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
207d1c0 to
58c0968
Compare
| var mediaToAttach = mutableListOf<MediaData>() | ||
|
|
||
| suspend fun onMediaAttach() { | ||
| val mediaData = uploadMedia() |
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.
Seems need to add uploadMedia method for all other platforms
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
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.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@src/pages/docs/chat/rooms/replies.mdx`:
- Around line 66-99: The React reply example uses "createdAt" for the reply
metadata while Swift/Kotlin/JS use "timestamp"; update the React example so the
metadata key is "reply.timestamp" (replace createdAt with timestamp) to match
other language examples and ensure cross-platform consistency, and while here
confirm that the Kotlin usage of replyToMessage.timestamp is in milliseconds (or
convert it to ms like Swift does) so all examples supply timestamp as epoch
milliseconds.
📜 Review details
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Jira integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (4)
src/pages/docs/chat/rooms/history.mdxsrc/pages/docs/chat/rooms/media.mdxsrc/pages/docs/chat/rooms/message-reactions.mdxsrc/pages/docs/chat/rooms/replies.mdx
🔇 Additional comments (11)
src/pages/docs/chat/rooms/history.mdx (1)
57-57: LGTM!The Swift parameter label correction from
withOptionstowithParamsaligns with the SDK documentation URL referenced on line 11 (history(withparams:)).src/pages/docs/chat/rooms/message-reactions.mdx (1)
318-352: LGTM!The Swift and Kotlin examples for removing message reactions are consistent with the existing send reaction patterns earlier in the file (lines 122-162) and mirror the JavaScript/React examples.
src/pages/docs/chat/rooms/replies.mdx (3)
170-202: LGTM!The
prepareReplyhelper functions are consistent across Swift, Kotlin, and Jetpack, properly extracting and formatting parent message data for reply metadata.
233-275: LGTM!The
fetchParentMessageimplementations properly handle serial extraction with appropriate error handling for each platform (Swift usesNSError, Kotlin throwsIllegalArgumentException).
337-427: LGTM!The display reply implementations correctly handle metadata extraction using platform-appropriate patterns (Swift pattern matching, Kotlin null-safe operators). The Jetpack Compose example properly manages subscription lifecycle with
DisposableEffect.src/pages/docs/chat/rooms/media.mdx (6)
80-148: LGTM!The
MediaDatastruct andonMediaAttachflow implementations are consistent across Swift, Kotlin, and Jetpack Compose, properly managing the media attachment state.Note: The
uploadMedia()function referenced in Swift/Kotlin/Jetpack is assumed to be a placeholder that users implement, matching the pattern established in the JavaScript example at lines 29-44.
214-329: LGTM!The send message implementations properly construct JSON metadata containing the media array using platform-appropriate patterns (Swift
JSONValueenums, KotlinbuildJsonObject/buildJsonArray).
366-450: LGTM!The
getValidMediaimplementations properly validate media IDs using regex and safely extract typed values from JSON metadata. The validation approach is consistent with security best practices mentioned in the documentation.
515-623: LGTM!The display implementations demonstrate platform-appropriate UI patterns. The Swift (UIKit) and Kotlin (Android Views) examples include helpful comments indicating where image loading libraries should be integrated, while the Jetpack Compose example shows a complete implementation using Coil's
AsyncImage.
669-780: LGTM!The
addMediaToMessageimplementations correctly handle metadata mutation by preserving existing metadata while adding new media entries. The Kotlin/Jetpack approach of rebuilding the metadata object maintains immutability.
829-947: LGTM!The
removeMediaFromMessageimplementations properly filter out the target media ID while preserving other metadata. Early returns for empty media arrays prevent unnecessary API calls.
✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.
| ```swift | ||
| func sendReply(replyToMessage: Message, replyText: String) async throws { | ||
| let metadata: MessageMetadata = [ | ||
| "reply": .object([ | ||
| "serial": .string(replyToMessage.serial), | ||
| "timestamp": .number(Double(replyToMessage.timestamp.timeIntervalSince1970 * 1000)), | ||
| "clientId": .string(replyToMessage.clientID), | ||
| "previewText": .string(String(replyToMessage.text.prefix(140))) | ||
| ]) | ||
| ] | ||
|
|
||
| try await room.messages.send(params: .init( | ||
| text: replyText, | ||
| metadata: metadata | ||
| )) | ||
| } | ||
| ``` | ||
|
|
||
| ```kotlin | ||
| suspend fun sendReply(replyToMessage: Message, replyText: String) { | ||
| val metadata = buildJsonObject { | ||
| put("reply", buildJsonObject { | ||
| put("serial", replyToMessage.serial) | ||
| put("timestamp", replyToMessage.timestamp) | ||
| put("clientId", replyToMessage.clientId) | ||
| put("previewText", replyToMessage.text.take(140)) | ||
| }) | ||
| } | ||
|
|
||
| room.messages.send( | ||
| text = replyText, | ||
| metadata = metadata | ||
| ) | ||
| } |
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.
🧩 Analysis chain
🏁 Script executed:
# First, let's check the file exists and get its size
wc -l src/pages/docs/chat/rooms/replies.mdxRepository: ably/docs
Length of output: 94
🏁 Script executed:
# Read the relevant sections of the file to verify timestamp field names
# Check around line 23 (JS timestamp), line 46 (React createdAt), line 71 (Swift timestamp), line 89 (Kotlin timestamp)
sed -n '1,50p' src/pages/docs/chat/rooms/replies.mdx | cat -nRepository: ably/docs
Length of output: 2015
🏁 Script executed:
# Continue reading from line 50 onwards to capture lines 66-99 mentioned in the review
sed -n '50,110p' src/pages/docs/chat/rooms/replies.mdx | cat -nRepository: ably/docs
Length of output: 1996
🏁 Script executed:
# Search for other references to Message.timestamp or timestamp handling in the docs
rg "timestamp|createdAt" src/pages/docs/chat/rooms/ -A 2 -B 2 | head -100Repository: ably/docs
Length of output: 8933
🏁 Script executed:
# Check if there's any clarification about timestamp format (milliseconds) in the messages documentation
cat src/pages/docs/chat/rooms/messages.mdx | grep -A 5 -B 5 "timestamp\|millisecond" | head -80Repository: ably/docs
Length of output: 4572
Fix React example to use timestamp instead of createdAt for metadata field consistency.
The React example uses createdAt as the reply metadata field name, while JavaScript, Swift, and Kotlin all use timestamp. This inconsistency across all language examples will cause issues for developers implementing cross-platform reply functionality. Update the React example at line 46 to match the field name used in other languages.
Additionally, verify that the Kotlin example's replyToMessage.timestamp is already in milliseconds to match the explicit conversion used in Swift (timeIntervalSince1970 * 1000).
🤖 Prompt for AI Agents
In `@src/pages/docs/chat/rooms/replies.mdx` around lines 66 - 99, The React reply
example uses "createdAt" for the reply metadata while Swift/Kotlin/JS use
"timestamp"; update the React example so the metadata key is "reply.timestamp"
(replace createdAt with timestamp) to match other language examples and ensure
cross-platform consistency, and while here confirm that the Kotlin usage of
replyToMessage.timestamp is in milliseconds (or convert it to ms like Swift
does) so all examples supply timestamp as epoch milliseconds.
Summary by CodeRabbit
Documentation
withOptionsrenamed towithParamsfor chat history queries✏️ Tip: You can customize this high-level summary in your review settings.