fix: remove duplicate placeholder rendering in phase-based content closure#363
fix: remove duplicate placeholder rendering in phase-based content closure#363kirillsh wants to merge 1 commit intoSDWebImage:masterfrom
Conversation
…osure The else branch rendered the placeholder content twice: once directly via content() and once via setupInitialState() -> setupPlaceholder(). This caused semi-transparent placeholder colors to appear darker than expected due to double-layering in the ZStack.
|
No actionable comments were generated in the recent review. 🎉 📝 WalkthroughWalkthroughA single-line modification to WebImage.swift that removes early placeholder rendering based on error state, delegating error and empty state handling to the setupInitialState() method during the initialization phase instead. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Tip Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord. 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 |
Problem
When using the phase-based content closure API, the placeholder content is rendered twice in the ZStack — once directly via
content()and once viasetupInitialState()→setupPlaceholder().This causes semi-transparent placeholder colors to appear darker than expected due to double-layering.
For example, a 5% black placeholder (
Color.black.opacity(0.05)) renders at ~9.75% effective opacity instead of 5%.Solution
Remove the redundant
content()call from theelsebranch.setupInitialState()already returns the placeholder viasetupPlaceholder(), which calls the samecontent()with the same phase and additionally applies.id(imageModel.url)for correct SwiftUI view identity tracking.Summary by CodeRabbit