-
Notifications
You must be signed in to change notification settings - Fork 135
Fix profile pictures avatar #136
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
Conversation
|
@Saud12131 is attempting to deploy a commit to the AJEET PRATAP SINGH's projects Team on Vercel. A member of the Team first needs to authorize it. |
WalkthroughThe changes configure Next.js image optimization to allow external profile images from Google and GitHub domains, then update the ProfilePic component to dynamically render authenticated user profile images from NextAuth sessions with a fallback to a default asset. Changes
Sequence DiagramsequenceDiagram
participant Browser
participant ProfilePic as ProfilePic Component
participant NextAuth as NextAuth
participant NextImage as Next.js Image
participant ImageSource as Image Source<br/>(Google/GitHub)
Browser->>ProfilePic: Render component
ProfilePic->>NextAuth: useSession()
NextAuth-->>ProfilePic: session?.user?.image
alt Session image available
ProfilePic->>NextImage: src: session.user.image
else No session image
ProfilePic->>NextImage: src: default asset
end
rect rgb(200, 220, 240)
Note over NextImage: Optimized via allowlisted<br/>external domains
NextImage->>ImageSource: Fetch image
ImageSource-->>NextImage: Image data
end
NextImage-->>Browser: Rendered image
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Comment |
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
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
apps/web/src/components/dashboard/ProfilePic.tsx (1)
10-16: Fix the image dimension mismatch.The
widthandheightprops are set to 10 pixels, but the container displays at 32px (h-8 w-8 in Tailwind). This severe mismatch will cause blurry, low-quality profile pictures because Next.js optimizes the image at 10px but then scales it up 3.2x for display.Apply this diff to match the actual display size:
<Image alt="User Profile" src={session?.user?.image||imgUrl} className="w-full h-full object-cover" - width={10} - height={10} + width={32} + height={32} ></Image>
🧹 Nitpick comments (1)
apps/web/src/components/dashboard/ProfilePic.tsx (1)
7-12: Consider adding a loading state.While the fallback to the default image is functional,
useSessioninitially returnsundefinedduring the first render, which causes a brief flash when the actual profile picture loads.You can improve the UX by checking the session status:
export const ProfilePic = () => { - const { data: session } = useSession(); + const { data: session, status } = useSession(); return ( <div className="rounded-full overflow-hidden inline-block h-8 w-8 border"> <Image alt="User Profile" - src={session?.user?.image||imgUrl} + src={status === "authenticated" && session?.user?.image ? session.user.image : imgUrl} className="w-full h-full object-cover" width={32} height={32} ></Image> </div> ); };
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (2)
apps/web/next.config.js(1 hunks)apps/web/src/components/dashboard/ProfilePic.tsx(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
apps/web/src/components/dashboard/ProfilePic.tsx (1)
apps/web/src/lib/auth/config.ts (1)
session(36-42)
🔇 Additional comments (1)
apps/web/src/components/dashboard/ProfilePic.tsx (1)
5-7: No configuration changes required—the session callback correctly preservesuser.imagefrom providers.The auth configuration uses Google and Github providers, both of which return
imagein the user object by default. The session callback spreads...session, which preserves the entire session object including the user with its image field. The code in ProfilePic.tsx correctly accessessession?.user?.imagewith an appropriate fallback.
|
@Saud12131 hey, it's going to be fixed in this #125 |
https://github.com/user-attachments/assets/66237f51-2074-4b46-83c5-4d8fc3be962e
did i have to change anything in it?
Summary by CodeRabbit