From 14defb16a1bdacd06a8e7bd8196fa74783150416 Mon Sep 17 00:00:00 2001 From: Sinclair Chen Date: Thu, 6 Jun 2024 13:34:38 -0700 Subject: [PATCH] Make image error code more robust I was trying to fix the image flicker issue - but that's just a chrome bug when the debug panel is open --- web/pages/[username]/[contractSlug].tsx | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/web/pages/[username]/[contractSlug].tsx b/web/pages/[username]/[contractSlug].tsx index 3f1adb7387..711d2dd473 100644 --- a/web/pages/[username]/[contractSlug].tsx +++ b/web/pages/[username]/[contractSlug].tsx @@ -266,7 +266,14 @@ export function ContractPageContent(props: ContractParams) { } }, [pointsString, newBets.length]) - const { isResolved, outcomeType, resolution, closeTime, creatorId } = contract + const { + isResolved, + outcomeType, + resolution, + closeTime, + creatorId, + coverImageUrl, + } = contract const isAdmin = useAdmin() const isMod = useTrusted() @@ -274,11 +281,7 @@ export function ContractPageContent(props: ContractParams) { const isClosed = !!(closeTime && closeTime < Date.now()) const [showResolver, setShowResolver] = useState(false) const [showReview, setShowReview] = useState(false) - const [coverImageUrl, setCoverImageUrl] = useState(contract.coverImageUrl) - // unhide on upload - useEffect(() => { - setCoverImageUrl(contract.coverImageUrl) - }, [contract.coverImageUrl]) + const [imageError, setImageError] = useState(false) useSaveReferral(user, { defaultReferrerUsername: contract.creatorUsername, @@ -356,7 +359,7 @@ export function ContractPageContent(props: ContractParams) { : 'top-[-92px] h-[140px]' )} > - {coverImageUrl && ( + {coverImageUrl && !imageError && (