From faef804e13fc87e5affafb646195abd5b64af0be Mon Sep 17 00:00:00 2001 From: Michael Song Date: Sat, 20 Jun 2026 23:28:42 -0400 Subject: [PATCH 1/2] fix company logo bugs --- .../src/app/_components/roles/role-info.tsx | 2 +- packages/ui/src/logo.tsx | 27 ++++++++++++++++--- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/apps/web/src/app/_components/roles/role-info.tsx b/apps/web/src/app/_components/roles/role-info.tsx index 5acd664e..32ae13cc 100644 --- a/apps/web/src/app/_components/roles/role-info.tsx +++ b/apps/web/src/app/_components/roles/role-info.tsx @@ -38,7 +38,7 @@ export function RoleInfo({ className, roleObj, onBack }: RoleCardProps) { const companyQuery = api.company.getById.useQuery( { id: roleObj.companyId }, - { enabled: !!reviews.data?.[0]?.companyId }, + { enabled: !!roleObj.companyId }, ); // ===== ROLE DATA ===== // diff --git a/packages/ui/src/logo.tsx b/packages/ui/src/logo.tsx index 73e32091..a12db35f 100644 --- a/packages/ui/src/logo.tsx +++ b/packages/ui/src/logo.tsx @@ -1,6 +1,6 @@ "use client"; -import { useState } from "react"; +import { useEffect, useState } from "react"; import Image from "next/image"; import type { CompanyType } from "../../db/src/schema/companies"; @@ -11,13 +11,27 @@ interface ILogoProps { company: Omit & { slug?: string }; } +// A transient first-load failure (cold image optimizer, logo.dev rate limiting +// under a burst of requests) used to latch the fallback permanently. Allow one +// retry before giving up so the logo recovers without a full remount. +const MAX_LOGO_RETRIES = 1; + const Logo: React.FC = ({ company, className }) => { const rawWebsite = company.website; const website = rawWebsite && rawWebsite !== "" - ? rawWebsite.replace(/^(https?:\/\/)/, "") + ? rawWebsite.replace(/^(https?:\/\/)/, "").replace(/\s/g, "") : `${company.name.replace(/\s/g, "")}.com`; const [imageError, setImageError] = useState(false); + const [retries, setRetries] = useState(0); + + // Reset the failed state when the target logo changes (e.g. navigating + // between companies) so a previous company's failure doesn't stick. + useEffect(() => { + setImageError(false); + setRetries(0); + }, [website]); + return imageError ? (
= ({ company, className }) => {
) : ( {`Logo setImageError(true)} + onError={() => { + if (retries < MAX_LOGO_RETRIES) { + setRetries((r) => r + 1); + } else { + setImageError(true); + } + }} /> ); }; From d6d55174988f5c814b09dd60794ed7d60b9ae293 Mon Sep 17 00:00:00 2001 From: Michael Song Date: Mon, 22 Jun 2026 21:13:17 -0400 Subject: [PATCH 2/2] Tidy Logo retry comments Co-Authored-By: Claude Opus 4.8 (1M context) --- packages/ui/src/logo.tsx | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/packages/ui/src/logo.tsx b/packages/ui/src/logo.tsx index a12db35f..7b6b98fa 100644 --- a/packages/ui/src/logo.tsx +++ b/packages/ui/src/logo.tsx @@ -11,9 +11,6 @@ interface ILogoProps { company: Omit & { slug?: string }; } -// A transient first-load failure (cold image optimizer, logo.dev rate limiting -// under a burst of requests) used to latch the fallback permanently. Allow one -// retry before giving up so the logo recovers without a full remount. const MAX_LOGO_RETRIES = 1; const Logo: React.FC = ({ company, className }) => { @@ -25,8 +22,7 @@ const Logo: React.FC = ({ company, className }) => { const [imageError, setImageError] = useState(false); const [retries, setRetries] = useState(0); - // Reset the failed state when the target logo changes (e.g. navigating - // between companies) so a previous company's failure doesn't stick. + // so that the logo is re-rendered when the website changes and error state's reset useEffect(() => { setImageError(false); setRetries(0);