diff --git a/src/components/BottomNav.tsx b/src/components/BottomNav.tsx index c1866bc..8340737 100644 --- a/src/components/BottomNav.tsx +++ b/src/components/BottomNav.tsx @@ -1,4 +1,5 @@ import { useNavigate, useLocation } from 'react-router-dom' +import { useState } from 'react' import { useAuth } from '../contexts/AuthContext' export default function BottomNav() { @@ -6,7 +7,9 @@ export default function BottomNav() { const location = useLocation() const { user, mongoUser } = useAuth() const displayName = mongoUser?.displayName || user?.displayName || 'U' - const photoURL = (mongoUser && 'photoURL' in mongoUser) ? (mongoUser.photoURL || null) : (user?.photoURL || null) + const mongoPhoto = mongoUser && 'photoURL' in mongoUser ? mongoUser.photoURL : null + const photoURL = (mongoPhoto?.startsWith('data:')) ? mongoPhoto : (user?.photoURL || null) + const [imgError, setImgError] = useState(false) const isActive = (path: string) => location.pathname === path @@ -54,8 +57,8 @@ export default function BottomNav() { onClick={() => navigate('/settings')} aria-label="Settings" > - {photoURL ? ( - {displayName} + {photoURL && !imgError ? ( + {displayName} setImgError(true)} /> ) : (
{displayName.charAt(0).toUpperCase()} diff --git a/src/pages/SettingsPage.tsx b/src/pages/SettingsPage.tsx index 8754300..aced983 100644 --- a/src/pages/SettingsPage.tsx +++ b/src/pages/SettingsPage.tsx @@ -77,8 +77,9 @@ export default function SettingsPage() { } const displayName = mongoUser?.displayName || user?.displayName || 'User' - // Prefer mongo photo; only fall back to Google photo if mongo has no photo set - const photoURL = (mongoUser && 'photoURL' in mongoUser) ? (mongoUser.photoURL || null) : (user?.photoURL || null) + // Use custom uploaded photo (base64) if set, otherwise always use Firebase's fresh Google URL + const mongoPhoto = mongoUser && 'photoURL' in mongoUser ? mongoUser.photoURL : null + const photoURL = (mongoPhoto?.startsWith('data:')) ? mongoPhoto : (user?.photoURL || null) const openEditModal = () => { setEditName(displayName) @@ -206,9 +207,11 @@ export default function SettingsPage() {
{/* Profile Section */}
-
+
{photoURL ? ( - {displayName} + {displayName} { (e.target as HTMLImageElement).style.display = 'none'; }} + /> ) : (
{displayName.charAt(0).toUpperCase()} @@ -465,9 +468,18 @@ export default function SettingsPage() {
e.stopPropagation()}>

Edit Profile

-
fileInputRef.current?.click()}> +
+ {editPhotoPreview && (