Conversation
📝 WalkthroughWalkthroughAdds client-side image loading state and fallback flow (optimized → unoptimized → placeholder) to WaveDropAuthorPfp, and includes a new CloudFront images prefix in image.helpers to enable scaling for that domain. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 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.
🧹 Nitpick comments (1)
components/waves/drops/WaveDropAuthorPfp.tsx (1)
21-32: Consider extracting the mode type for DRY.The union type
"optimized" | "unoptimized" | "placeholder"is repeated three times. Extracting it would reduce repetition and make future changes easier.♻️ Suggested refactor
+type LoadMode = "optimized" | "unoptimized" | "placeholder"; + const WaveDropAuthorPfp: React.FC<WaveDropAuthorPfpProps> = ({ drop }) => { const compact = useCompactMode(); const resolvedPfp = drop.author.pfp ? resolveIpfsUrlSync(drop.author.pfp) : null; const [loadState, setLoadState] = useState<{ src: string | null; - mode: "optimized" | "unoptimized" | "placeholder"; + mode: LoadMode; }>({ src: null, mode: "optimized", }); - const loadMode: "optimized" | "unoptimized" | "placeholder" = + const loadMode: LoadMode = loadState.src === resolvedPfp ? loadState.mode : "optimized"; - const setLoadMode = (mode: "optimized" | "unoptimized" | "placeholder") => { + const setLoadMode = (mode: LoadMode) => { setLoadState({ src: resolvedPfp, mode }); };🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@components/waves/drops/WaveDropAuthorPfp.tsx` around lines 21 - 32, Extract the repeated union type into a single type alias (e.g., declare type LoadMode = "optimized" | "unoptimized" | "placeholder") and update the useState generic, the loadMode variable's type, and the setLoadMode parameter to use LoadMode instead of repeating the literal union; ensure loadState state shape remains { src: string | null; mode: LoadMode } and that functions/variables loadState, loadMode, and setLoadMode reference the new LoadMode alias.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@components/waves/drops/WaveDropAuthorPfp.tsx`:
- Around line 21-32: Extract the repeated union type into a single type alias
(e.g., declare type LoadMode = "optimized" | "unoptimized" | "placeholder") and
update the useState generic, the loadMode variable's type, and the setLoadMode
parameter to use LoadMode instead of repeating the literal union; ensure
loadState state shape remains { src: string | null; mode: LoadMode } and that
functions/variables loadState, loadMode, and setLoadMode reference the new
LoadMode alias.
ℹ️ Review info
Configuration used: defaults
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (2)
components/waves/drops/WaveDropAuthorPfp.tsxhelpers/image.helpers.ts
|
There was a problem hiding this comment.
🧹 Nitpick comments (1)
components/waves/drops/WaveDropAuthorPfp.tsx (1)
57-66: Make unoptimized fallback use the original URL, not the scaled URL.Right now both modes still request
getScaledImageUri(...). If the scaled path itself is bad/unavailable, the unoptimized retry cannot recover. Consider switchingsrctoresolvedPfpin unoptimized mode.♻️ Proposed refactor
+ const optimizedPfp = + resolvedPfp ? getScaledImageUri(resolvedPfp, ImageScale.W_AUTO_H_50) : null; + const imageSrc = + loadMode === "optimized" ? optimizedPfp : resolvedPfp; + const avatarContent = resolvedPfp === null || loadMode === "placeholder" ? ( <div className="tw-h-full tw-w-full tw-rounded-lg tw-bg-iron-900 tw-ring-1 tw-ring-inset tw-ring-white/10" /> ) : ( <Image - key={`${resolvedPfp}-${loadMode}`} - src={getScaledImageUri(resolvedPfp, ImageScale.W_AUTO_H_50)} + key={`${imageSrc}-${loadMode}`} + src={imageSrc} alt={ authorHandle ? `${authorHandle}'s profile picture` : "Profile picture" }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@components/waves/drops/WaveDropAuthorPfp.tsx` around lines 57 - 66, The Image currently always uses getScaledImageUri(resolvedPfp, ImageScale.W_AUTO_H_50) so when the scaled URL fails the unoptimized retry also requests the same bad URL; update the src prop in WaveDropAuthorPfp (the Image element that references getScaledImageUri, resolvedPfp and loadMode) to use the original resolvedPfp when loadMode === "unoptimized" (i.e., choose getScaledImageUri(...) for optimized mode and resolvedPfp for unoptimized mode) while keeping the unoptimized prop and onError handler unchanged so the fallback truly retries the original image URL.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@components/waves/drops/WaveDropAuthorPfp.tsx`:
- Around line 57-66: The Image currently always uses
getScaledImageUri(resolvedPfp, ImageScale.W_AUTO_H_50) so when the scaled URL
fails the unoptimized retry also requests the same bad URL; update the src prop
in WaveDropAuthorPfp (the Image element that references getScaledImageUri,
resolvedPfp and loadMode) to use the original resolvedPfp when loadMode ===
"unoptimized" (i.e., choose getScaledImageUri(...) for optimized mode and
resolvedPfp for unoptimized mode) while keeping the unoptimized prop and onError
handler unchanged so the fallback truly retries the original image URL.



Summary by CodeRabbit
Bug Fixes
New Features