Skip to content

Commit

Permalink
fix: should not show broken image (#2526)
Browse files Browse the repository at this point in the history
  • Loading branch information
louis-jan committed Mar 28, 2024
1 parent 3b3eb11 commit 6e01e04
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions web/screens/ExploreModels/ExploreModelItemHeader/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useCallback } from 'react'
import { useCallback, useState } from 'react'

import { Model } from '@janhq/core'
import {
Expand Down Expand Up @@ -70,6 +70,7 @@ const ExploreModelItemHeader: React.FC<Props> = ({ model, onClick, open }) => {
const { requestCreateNewThread } = useCreateNewThread()
const totalRam = useAtomValue(totalRamAtom)
const { settings } = useSettings()
const [imageLoaded, setImageLoaded] = useState(true)

const nvidiaTotalVram = useAtomValue(nvidiaTotalVramAtom)
const setMainViewState = useSetAtom(mainViewStateAtom)
Expand Down Expand Up @@ -143,9 +144,10 @@ const ExploreModelItemHeader: React.FC<Props> = ({ model, onClick, open }) => {
className="cursor-pointer rounded-t-md bg-background"
onClick={onClick}
>
{model.metadata.cover && (
<div className="relative h-full w-full ">
{model.metadata.cover && imageLoaded && (
<div className="relative h-full w-full">
<img
onError={() => setImageLoaded(false)}
src={model.metadata.cover}
className="h-[250px] w-full object-cover"
alt={`Cover - ${model.id}`}
Expand Down

0 comments on commit 6e01e04

Please sign in to comment.