Skip to content

Commit 0157a7b

Browse files
committed
fix: remove unused state and simplify image rendering logic in DidAvatar component
1 parent 9113733 commit 0157a7b

File tree

1 file changed

+1
-7
lines changed

1 file changed

+1
-7
lines changed

packages/webapp/src/components/shared/DidAvatar.tsx

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import { useState } from "react"
2-
31
import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar"
42
import { cn } from "@/lib/utils"
53
import { useConnectionStore } from "@/stores/connection"
@@ -34,23 +32,19 @@ interface DidAvatarProps {
3432

3533
export function DidAvatar({ did, avatarUrl, className }: DidAvatarProps) {
3634
const nodeUrl = useConnectionStore((state) => state.nodeUrl)
37-
const [imgError, setImgError] = useState(false)
3835

3936
// Resolve relative paths (e.g. /api/v1/profile/avatar) against the node URL
4037
const resolvedUrl =
4138
avatarUrl && avatarUrl.startsWith("/") && nodeUrl
4239
? `${nodeUrl.replace(/\/$/, "")}${avatarUrl}`
4340
: avatarUrl
4441

45-
const showImage = Boolean(resolvedUrl) && !imgError
46-
4742
return (
4843
<Avatar className={cn("size-9", className)}>
49-
{showImage && (
44+
{resolvedUrl && (
5045
<AvatarImage
5146
src={resolvedUrl}
5247
alt={did}
53-
onError={() => setImgError(true)}
5448
/>
5549
)}
5650
<AvatarFallback style={{ backgroundColor: colorForDid(did), color: "white" }}>

0 commit comments

Comments
 (0)