fix: should not show broken image (#2526)
This commit is contained in:
parent
3b3eb119f0
commit
6e01e04c76
@ -1,4 +1,4 @@
|
|||||||
import { useCallback } from 'react'
|
import { useCallback, useState } from 'react'
|
||||||
|
|
||||||
import { Model } from '@janhq/core'
|
import { Model } from '@janhq/core'
|
||||||
import {
|
import {
|
||||||
@ -70,6 +70,7 @@ const ExploreModelItemHeader: React.FC<Props> = ({ model, onClick, open }) => {
|
|||||||
const { requestCreateNewThread } = useCreateNewThread()
|
const { requestCreateNewThread } = useCreateNewThread()
|
||||||
const totalRam = useAtomValue(totalRamAtom)
|
const totalRam = useAtomValue(totalRamAtom)
|
||||||
const { settings } = useSettings()
|
const { settings } = useSettings()
|
||||||
|
const [imageLoaded, setImageLoaded] = useState(true)
|
||||||
|
|
||||||
const nvidiaTotalVram = useAtomValue(nvidiaTotalVramAtom)
|
const nvidiaTotalVram = useAtomValue(nvidiaTotalVramAtom)
|
||||||
const setMainViewState = useSetAtom(mainViewStateAtom)
|
const setMainViewState = useSetAtom(mainViewStateAtom)
|
||||||
@ -143,9 +144,10 @@ const ExploreModelItemHeader: React.FC<Props> = ({ model, onClick, open }) => {
|
|||||||
className="cursor-pointer rounded-t-md bg-background"
|
className="cursor-pointer rounded-t-md bg-background"
|
||||||
onClick={onClick}
|
onClick={onClick}
|
||||||
>
|
>
|
||||||
{model.metadata.cover && (
|
{model.metadata.cover && imageLoaded && (
|
||||||
<div className="relative h-full w-full">
|
<div className="relative h-full w-full">
|
||||||
<img
|
<img
|
||||||
|
onError={() => setImageLoaded(false)}
|
||||||
src={model.metadata.cover}
|
src={model.metadata.cover}
|
||||||
className="h-[250px] w-full object-cover"
|
className="h-[250px] w-full object-cover"
|
||||||
alt={`Cover - ${model.id}`}
|
alt={`Cover - ${model.id}`}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user