compose: Derive Giphy ratio from the downloaded GIF when dimensions are missing#6551
compose: Derive Giphy ratio from the downloaded GIF when dimensions are missing#6551gpunto wants to merge 1 commit into
Conversation
PR checklist ✅All required conditions are satisfied:
🎉 Great job! This PR is ready for review. |
SDK Size Comparison 📏
|
|
WalkthroughGiphyAttachmentContent is updated to compute fallback display dimensions using the downloaded image's intrinsic aspect ratio. A new downloadedRatio state tracks the loaded fallback image's size, driving conditional rendering with a shimmer placeholder versus the normal Giphy image path. ChangesGiphy Fallback Aspect-Ratio Sizing
Estimated code review effort: 2 (Simple) | ~15 minutes Possibly related PRs
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/attachments/content/GiphyAttachmentContent.kt (1)
262-266: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueConsider
SideEffectinstead ofLaunchedEffectfor a synchronous state update.The block performs a plain, non-suspending state assignment;
SideEffectavoids spinning up a coroutine for this and better conveys intent.♻️ Suggested refactor
- val intrinsicSize = painter?.intrinsicSize - LaunchedEffect(intrinsicSize) { - if (intrinsicSize != null && intrinsicSize.isSpecified && intrinsicSize.height > 0f) { - downloadedRatio = intrinsicSize.width / intrinsicSize.height - } - } + val intrinsicSize = painter?.intrinsicSize + SideEffect { + if (intrinsicSize != null && intrinsicSize.isSpecified && intrinsicSize.height > 0f) { + downloadedRatio = intrinsicSize.width / intrinsicSize.height + } + }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/attachments/content/GiphyAttachmentContent.kt` around lines 262 - 266, Replace the `LaunchedEffect(intrinsicSize)` block in `GiphyAttachmentContent` with `SideEffect` because the body only performs a synchronous `downloadedRatio` assignment and does not need a coroutine. Keep the same `intrinsicSize` guard and update logic, but use `SideEffect` so the intent of a non-suspending state update is clearer.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In
`@stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/attachments/content/GiphyAttachmentContent.kt`:
- Around line 254-277: The Giphy fallback in GiphyAttachmentContent currently
only checks whether the painter is null, so AsyncImagePainter.State.Error is
treated like a loading state and can leave the shimmer up indefinitely. Update
the StreamAsyncImage content branch to inspect imageState directly, handle the
error state separately with a dedicated placeholder, and keep the existing
loaded and loading behavior in the fallback path.
---
Nitpick comments:
In
`@stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/attachments/content/GiphyAttachmentContent.kt`:
- Around line 262-266: Replace the `LaunchedEffect(intrinsicSize)` block in
`GiphyAttachmentContent` with `SideEffect` because the body only performs a
synchronous `downloadedRatio` assignment and does not need a coroutine. Keep the
same `intrinsicSize` guard and update logic, but use `SideEffect` so the intent
of a non-suspending state update is clearer.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 57c424b3-3c90-4e88-8a0d-bd85c3bdbe1c
⛔ Files ignored due to path filters (1)
stream-chat-android-compose/src/test/snapshots/images/io.getstream.chat.android.compose.ui.attachments.content_AttachmentsContentTest_giphy_attachment_content.pngis excluded by!**/*.png
📒 Files selected for processing (1)
stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/attachments/content/GiphyAttachmentContent.kt


Goal
When a Giphy attachment has no dimensions metadata (e.g. GIFs synced from another platform),
GiphyAttachmentContentrendered a hardcoded container size withContentScale.Crop, cropping portrait and landscape GIFs. Derive the container aspect ratio from the downloaded GIF instead.Closes AND-1296
Implementation
giphyInfo == null), measure the downloaded GIF's intrinsic size via Coil and size the container to that aspect ratio, clamped to the configured max dimensions.UI Changes
Testing
giphy attachment contentPaparazzi snapshot andverifyPaparazziDebugpasses.Summary by CodeRabbit