feat: wrap blurhash rendering in ErrorBoundary for improved error handling

Signed-off-by: Innei <tukon479@gmail.com>
This commit is contained in:
Innei 2025-06-28 22:44:34 +08:00
parent c374609563
commit ef40845b54
No known key found for this signature in database
GPG Key ID: 0F62D33977F021F7
1 changed files with 11 additions and 8 deletions

View File

@ -1,6 +1,7 @@
import { nextFrame } from "@follow/utils/dom"
import { getImageProxyUrl } from "@follow/utils/img-proxy"
import { cn } from "@follow/utils/utils"
import { ErrorBoundary } from "@sentry/react"
import { useForceUpdate } from "motion/react"
import type { FC, ImgHTMLAttributes, VideoHTMLAttributes } from "react"
import * as React from "react"
@ -343,14 +344,16 @@ const MediaImpl: FC<MediaProps> = ({
}}
>
{props.blurhash && (
<span
className={cn(
"absolute inset-0 overflow-hidden rounded",
mediaLoadState === "loaded" && "animate-out fade-out-0 fill-mode-forwards",
)}
>
<BlurhashCanvas hash={props.blurhash} className="size-full" />
</span>
<ErrorBoundary>
<span
className={cn(
"absolute inset-0 overflow-hidden rounded",
mediaLoadState === "loaded" && "animate-out fade-out-0 fill-mode-forwards",
)}
>
<BlurhashCanvas hash={props.blurhash} className="size-full" />
</span>
</ErrorBoundary>
)}
</span>
</div>