diff --git a/src/pages/HomePage.jsx b/src/pages/HomePage.jsx index f1a771e..f19f2de 100644 --- a/src/pages/HomePage.jsx +++ b/src/pages/HomePage.jsx @@ -44,13 +44,15 @@ function HomePage() { useEffect(() => { setArtworkIndex(0); }, [expandedCardId]); useEffect(() => { - if (!expandedCardId || !expandedCard) return; - const imageId = expandedCard.image_ids?.[artworkIndex]; + if (!expandedCardId) return; + const card = cards.find(c => c.id === expandedCardId); + if (!card) return; + const imageId = card.image_ids?.[artworkIndex]; if (!imageId || cardImages[expandedCardId]?.[artworkIndex]) return; fetchCardImage(expandedCardId, imageId) .then(image => setCardImage(expandedCardId, artworkIndex, image)) .catch(err => console.error('Failed to load card image', err)); - }, [expandedCardId, artworkIndex, expandedCard, cardImages, setCardImage]); + }, [expandedCardId, artworkIndex, cards, cardImages, setCardImage]); const getTotal = useCallback((card) => card.printings?.reduce((sum, p) => {